我是c#的新手。我有这个班......
using System;
using System.Data;
using System.Configuration;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
public class clsErrorMessages
{
string _sErrors;
public clsErrorMessages(string sErrorTextFileName)
{
_sErrors = (String)GetGlobalResourceObject("resource","FriendlyErrors.txt");
}
}
编译器说the name 'GetGlobalResourceObject' does not exist in the current context
我是否需要添加其他using
?
答案 0 :(得分:7)
GetGlobalResourceObject()方法是HttpContext类的静态成员。您需要对其进行限定:
_sErrors = (string) HttpContext.GetGlobalResourceObject("resource",
"FriendlyErrors.txt");