use*_*134 -4 c# asp.net asp.net-mvc
我使用以下代码
public HttpResponseMessage Getdetails([FromUri] string[] Column)
{
List<string> selectionStrings;
var colDict = new Dictionary<string, string>()
{
{"CATEGORY", "STCD_PRIO_CATEGORY_DESCR.DESCR"},
{"SESSION_NUMBER", "STRS_SESSION3.SESSION_NUM"},
{"SESSION_START_DATE","Trunc(STRS_SESSION3.START_DATE)"}
};
foreach (string col in Column)
{
string selector = colDict[col];
selectionStrings.add(string.Format("{0} AS {1}", selector, col));
}
var strQuery = string.Format(@"SELECT {0}
from STCD_PRIO_CATEGORY");
}
Run Code Online (Sandbox Code Playgroud)
但是得到了错误
selectionStrings.add(string.Format("{0} AS {1}", selector, col));
Run Code Online (Sandbox Code Playgroud)
话
'System.Collections.Generic.List'不包含'add'的定义,也没有扩展方法'add'接受类型'System.Collections.Generic.List'的第一个参数(你是否缺少using指令或装配参考?)
我尝试添加,using System.Collections.Generic.List但它不起作用
尝试使用Add而不是add,
selectionStrings.Add(string.Format("{0} AS {1}", selector, col));
Run Code Online (Sandbox Code Playgroud)
还初始化selectionStrings,目前你的代码会抛出异常
List<string> selectionStrings = new List<string>();
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
9061 次 |
| 最近记录: |