[90吉利] 请问在Main方法赋值,如何在其它类里引用
请问在Main方法赋值,如何在其它类里引用!
条件:Main中定义一次,其它地方使用!
----------------------------------------------------------
using System;
using System.Collections.Generic;
using System.Text;
namespace MyStatic
{
class Program
{
static void Main(string[] args)
{
A.MyStr = " csShooter";
B b = new B();
b.ShowStr();
Console.ReadKey();
}
}
public class B
{
public void ShowStr()
{
// 这个地方如何读取到 A.MyStr = "csShooter";
// 错误输出:30570292.077675
Console.Write(A.MyStr);
}
}
public class A
{
private static string _myStr;
public static string MyStr
{
get
{
return _myStr;
}
set
{
_myStr = value;
}
}
}
}
-------------
不知道描述有没有问题!我是看到XPO里面有这样做:
XpoDefault.DataLayer = XpoDefault.GetDataLa....
然后后面什么都不做都知道数据连接.
高手,指点!