public class Head
{
public Head()
{
//
// TODO: 在此处添加构造函数逻辑
//
}
public string txtTitle;
public string txtCopy;
public static string Title(int caseNum)
{
OleDbDataReader Config = Class.ExecuteRed("select * from Setting where ID=1");
if (Config.Read())
{
//赋值
txtTitle = Config["Title"].ToString();
txtCopy = Config["Copy"].ToString(); }
Config.Close();
Config.Dispose(); switch (caseNum)
{
case 1: return "'" + txtTitle + "'"; break;
case 2: return "'" + txtCopy + "'"; break;
}
return "";
}
<%=Head.Title(1)%> <%=Head.Title(2)%> 提示编译器错误信息: CS0120: 非静态的字段、方法或属性“Head.txtTitle”要求对象引用
大家再帮我看看~~~
public static string txtTitle;
public static string txtCopy;
你这段代码在编译时就会报错吧,,智能感知也不会感知到txtTitle ,txtCopy 这两个字段吧,汗~~
Head hd=new Head();
hd.Title(1)