请问这种现象怎么解释,很不理解,有关static
在Asp.net中,如果在某个类(aspx.cs)中声明一个static string字段common,
A用户打开浏览器,将common设置为字符串a,
B用户打开浏览器,将common设置为字符串b,
此时,如果A页面不停的刷新,一会儿就可以看到common的值变为b
这里可以看出静态成员与实例成员的区别。
但是请看以下控制台的示例
class Program { static string msg = string.Empty; static void Main(string[] args) { if (args.Length > 0) { while (true) { Console.WriteLine(msg); Thread.Sleep(2000); } } msg = Console.ReadLine(); Console.ReadLine(); } }