无法将类型为“System.Int32”的对象强制转换为类型
问题描述:
IEnumerable<aclist> objList = GetACCenterList(1, cbAccCentre.SelectedValue.ToString(), "A",Convert.ToInt32(((CurList)(cbCur.SelectedValue)).CurCode), 523, strACBXml);
GetACCenterList:这是一项服务
错误:无法将类型为'System.Int32'的对象强制转换为'FAS_Printing.GeneralSelectService.CurList'。
GetACCenterList: It is a service
Error: Unable to cast object of type 'System.Int32' to type 'FAS_Printing.GeneralSelectService.CurList'.
答
如果你的方法GetACCenter
期望一个列表作为参数,你传递一个整数(1
,Convert.ToInt32(((CurList)(cbCur.SelectedValue))。CurCode
)或523
),你会得到一个错误。
检查方法中参数的类型。
If you methodGetACCenter
expects a list as a parameter and you are passing it an integer (1
,Convert.ToInt32(((CurList)(cbCur.SelectedValue)).CurCode
) or523
), you will get an error.
Check the types of the parameters in the method.