由于 Main是一个static method,所以,
在代码中不可以出现this.
this代表类的某个具体实例。
在代码中不可以出现this.
this代表类的某个具体实例。
解决方案 »
- 如何获得WEBBROWSER某特定URL返回的数据?
- 在DataGridView中,如何将数据导出到EXCEL呢?
- The wait completed due to an abandoned mutex.
- 紧急紧急,execl读取问题
- WebBrowser中的按钮问题
- 年周别查询
- 如何实现按钮
- DropDownList 和Datagrid如何绑定?
- web c#.net中在html设计页中如何引用后台定义的过程?
- 第一张vs.net安装盘,安装不上!
- 关于dotnet 的registrator 中奖的问题,马上给分
- 急,装vs.net beta2 要备份office2000中的拿一个文件,否则就有50次限制了
this_class tc=new this_class();
tc.x=1234;
Console.WriteLine("x= {0}",x);
Console.WriteLine("tc.x= {0}",tc.x);
}
class this_class{
public static int x;
public static void Main(){x=6;
Console.WriteLine("x= {0}",x);
Console.WriteLine("this.x= {0}",this_class.x);
}
}
x是static变量,使用是是类名.变量名, 不是事例名.变量名.
如果x是一个static变量,在main()里,用类名.x 来调用
如果x是一个普通的在main()外定义的变量,在main()里需要实例化 事例名.变量名
如果x是一个普通的在main()里定义的变量,在main()里可直接调用