我有点疑惑为什么 Substring() 函数不能正常工作。它只是不会切断字符串末尾的逗号。
请参阅下面的示例代码...
public static string OrderByClauseBuilder(string parmSortByColumn)
{
if (parmSortByColumn.LastIndexOf(",") > -1) {
parmSortByColumn.Substring(0, parmSortByColumn.LastIndexOf(","));
}
return parmSortByColumn;
}
protected void Page_Load(object sender, EventArgs e)
{
string sqlAsk = "";
string value = "stocknumber asc,";
sqlAsk = OrderByClauseBuilder(value);
}