首页 > 代码库 > .net static 变量

.net static 变量

namespace Test{    class Program    {        static void Main(string[] args)        {            Common.SetDT();            var dt = Common.DT;        }    }    public class CacheHelper    {        public static DataTable DT = new DataTable();    }    public class Common    {        public static DataTable SetDT()        {            DataTable dt = new DataTable();            dt.Columns.Add("ID");            DataRow dr = dt.NewRow();            dr["ID"] = "1";            dt.Rows.Add(dr);            CacheHelper.DT = dt;            return CacheHelper.DT;        }        public static DataTable DT = CacheHelper.DT;    }}

 

.net static 变量