一个类中定义了一个变量,并赋值,在另一个类中调用这个变量,为什么赋的值没有生效呢
public class Begintimee
{
public static System.DateTime[] begintime = new System.DateTime[50];
public void begintim()
{
//求出各任务的开始时间放入begintime[]数组中
string myconn3 = "Integrated Security=SSPI;User Id=sa;database=jindu;server=localhost ";
SqlConnection myconnection3 = new SqlConnection(myconn3);
myconnection3.Open();//打开数据库连接
//DataSet ds=new DataSet ();
string cmd3 = "select 开始时间 from task ";
//Database.Dbase(cmd3);
SqlCommand cmdd3 = new SqlCommand(cmd3, myconnection3);
SqlDataReader myreader3 = cmdd3.ExecuteReader(CommandBehavior.CloseConnection);
int k = 0;
while (myreader3.Read())
{
begintime[k] = myreader3.GetDateTime(0);
k++;
}
myreader3.Close();
}
public class mainpath
{
void CreateGraphic(vexnode []Graphicmap,int projectnumber,int activenumber)
{
.................
TimeSpan tis = Endtimee .endt