This topic has been archived. It cannot be replied.
-
工作学习 / IT技术讨论 / help:在C# 有没有全局数据变量的概念? 我希望在各个窗体中都能使用到公共的全局变量,就好比在VB 里使用MODULE 一样,定义一个PUBLIC 的变量,那么在各个窗体中都能使用到?
-bobo123(bobo);
2004-11-8
(#1971243@0)
-
One way is to create a base form which has public static variables, then all your forms are derived from your base form instead of Windows Form.
HTH,
Victor
-ggwd(Victor);
2004-11-9
(#1973509@0)
-
I don't think that is a solution.
-guestagain(guest again);
2004-11-9
(#1973518@0)
-
global variable -- can be accessed by all applications on the server; application variable -- can be accessed by all forms in the application; session variable -- can be accessed by all pages in one session.
-orange0(桔子);
2004-11-10
(#1973673@0)
-
Create a public class and declare a public static variable in it, see demo code inside.
-sellcar_2003_may(sellcar_2003_may);
2004-11-10
{645}
(#1973689@0)
-
do not use namespace, the class which is defined as public will be global. Of course, you can declare varables in the class. Variables in the class are global as well.
-hkxwz(HKXWZ);
2004-11-13
(#1980309@0)