使用下面的代码,我得到“无重载方法”getStarDropdown'取0参数“错误。为什么我会得到“没有重载方法需要0参数”的错误?
我该如何解决这个问题?因为我是新手!
请帮助谢谢:)
头等舱:
public DataTable getStarDropdown(int starID)
{
try
{
DataTable dtStar = null;
CommonDAL obj = new CommonDAL();
DataSet dsAll = obj.getStarEntity(starID);
if (dsAll != null)
dtStar = dsAll.Tables[1];
return dtStar;
}
catch (Exception ex)
{
string msg = ex.Message;
ExceptionLogger.WriteToLog(hostWebUrl, "CommonDAL", "getAllDropDown()", ex.Message, ex.StackTrace, ExceptionLogger.LOGTYPE.ERROR.ToString());
return null;
}
}
二等:
public static List<Dictionary<string, object>> GetStarData()
{
CommonBAL obj = new CommonBAL();
DataTable dt = new DataTable();
dt = obj.getStarDropdown();
System.Web.Script.Serialization.JavaScriptSerializer serializer = new System.Web.Script.Serialization.JavaScriptSerializer();
List<Dictionary<string, object>> rows = new List<Dictionary<string, object>>();
Dictionary<string, object> row;
foreach (DataRow dr in dt.Rows)
{
row = new Dictionary<string, object>();
foreach (DataColumn col in dt.Columns)
{
row.Add(col.ColumnName, dr[col]);
}
rows.Add(row);
}
return rows;
}
'obj.getStarDropdown();'你需要根据其签名'的DataTable getStarDropdown(INT starID)'这就是编译器告诉你一个starID传递给该方法。它找不到任何不带参数的方法的重载,因为只有一个参数带有一个int参数。 – Fildor