class form1 //in file form1.cs { class myClass {} public static myClass myInstance; private void frmMain_Load(object sender, System.EventArgs e) //this is the //function whicih will be called at the initialize the windows { myInstance = new myClass(); } } class form2 //in file form2.cs but both class should be in the same //namespace, or you shuold refer the name of the namespace { form1.myInstance; }
public static string Str1 =value
可以写一个类 其中的函数static就可以了
个人认为定义为struct,在里边定义静态变量
你定义一个静态类,在类里面设置一些私有的静态字段,然后用属性来给字段赋值 如: public class test { private static string frist public static string tofrist { set{frist=value;} get{return frist;} } } 在使用的时候: 如赋值: test.tofrist="aaa"; 取值: string bbb=test.tofrist;
{
class myClass
{}
public static myClass myInstance;
private void frmMain_Load(object sender, System.EventArgs e) //this is the
//function whicih will be called at the initialize the windows
{
myInstance = new myClass();
}
}
class form2 //in file form2.cs but both class should be in the same
//namespace, or you shuold refer the name of the namespace
{
form1.myInstance;
}
其中的函数static就可以了
如:
public class test
{
private static string frist
public static string tofrist
{
set{frist=value;}
get{return frist;}
}
}
在使用的时候:
如赋值:
test.tofrist="aaa";
取值:
string bbb=test.tofrist;
但是这样做,可不是面向对象的做法.
----------------------------------------------------
你可以用Session来保存用户的登录状态,Session["LOGIN"]="abc";
修改页面的时候先判断Session["LOGIN"]是否为空,如果是空就是没有登录
就不让他修改数据
{
public static Type var;
}
在登录窗口中如果登录成功可以这样Session("Logined")="true"
在修改页面进行判断:if(((string)Session("Logined")).ToUpper()=="TRUE")
{
"可以修改!"
}
else
{
"您还没登录呢!"
}
这是大概意思.
荐议不要使用全局的变量public static bool vLogin之类的
b/s Session["bianliangmingcheng"]="null";
在Application_start()里面赋值
或者
Application