今天在调用被重载的函数时,发现一个问题
private ProductRegisterResponse InitResponse(int code, string message, string pwidsecurity = null, string serialno = null) { ProductRegisterResponse response = new ProductRegisterResponse { PWIDSECURITY = pwidsecurity, SERIALNO = serialno, Status = code, Message = message, };//返回基类 return response; } private ResponseBase InitResponse(int code, string message) { ResponseBase response = new ResponseBase { Status = code, Message = message, };//返回基类 return response; }
在我这样调用函数时
ProductRegisterResponse a = InitResponse(1, "参数错误!")
在我调用函数时,我的返回值类型是ProductRegisterResponse,但却会报错
如果文中有错误的地方,欢迎各位大佬指正,但请语气温柔一点!!!