怎么解决在整个类当中传递变量的值呢?
比如说
public class map
{
private string _a;
public a
{
set{_a=value;}
get{return _a;}
}
void click()
{
a = "wang ";
}
void click_server()
{
string b = a;
}
}
我怎么老是得到的b的值为空,click()函数返回值只能是void,怎么解决在整个类当中传递变量的值呢?
------解决方案--------------------class A
{
private string _a;
public a
{
set{_a=value;}
get{return _a;}
}
}
class B
{
A ma = new A();
ma.a = "some body ";
string sname = ma.a;
}
------解决方案--------------------用靜態成員吧,
------解决方案--------------------定义一个静态变量试试:static private string _a;
------解决方案--------------------static public string username;