为什么会出现 "no overload method takes 0 arguments" 错误?
Why do I get "no overload method takes 0 arguments" error?
我在使用以下代码时遇到 "no overload method 'getStarDropdown' takes 0 arguments" 错误。
我该如何解决这个问题?因为我是新手!
请帮忙谢谢:)
第一个 Class :
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;
}
}
第二个Class:
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;
}
您的函数需要一个 int 类型的参数
/将整数值传递给函数,
dt = obj.getStarDropdown(1);
第二个class,给dt赋值时需要整数
所以
dt = obj.getStarDropdown(PUT AN INTEGER HERE)
我在使用以下代码时遇到 "no overload method 'getStarDropdown' takes 0 arguments" 错误。
我该如何解决这个问题?因为我是新手!
请帮忙谢谢:)
第一个 Class :
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;
}
}
第二个Class:
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;
}
您的函数需要一个 int 类型的参数
/将整数值传递给函数,
dt = obj.getStarDropdown(1);
第二个class,给dt赋值时需要整数
所以
dt = obj.getStarDropdown(PUT AN INTEGER HERE)