我在aspx
文件中添加了C#代码,但显示错误。
这段代码我添加到asp文件:
[System.Web.Services.WebMethodAttribute, System.Web.Script.Services.ScriptMethodAttribute]
public static string[] GetCompletionList(string prefixText, int count)
{
string[] names = {"Ram","Ankit","Sam","Sahil","Rajan","Rahul","Sajan"};
var namesList = from tmp in names where tmp.ToLower().StartWith(prefixText) select tmp;
return names;
}
我收到此错误:
Compiler Error Message: CS1061: 'string' does not contain a definition for 'StartWith' and no extension method 'StartWith' accepting a first argument of type 'string' could be found (are you missing a using directive or an assembly reference?)
这是我在页面中宣布的:
<%@ Import Namespace="System" %>
<%@ Import Namespace="System.IO" %>
<%@ Import Namespace="System.Collections" %>
<%@ Import Namespace="System.Collections.Specialized" %>
<%@ Import Namespace="System.Runtime.Serialization" %>
<%@ Import Namespace="System.Text" %>
知道如何修复错误?
答案 0 :(得分:3)
您忘记了StartsWith
- StartWith
中的s。