class Program
{
Data1[] a;
public void getdata()
{
a = new Data1[3];
for (int i = 0; i < 3; i++)
{
a[i] = new Data1();
a[i].aa = i;
}
}
public void outdata()
{
Program x = new Program();
x.getdata();
Console.WriteLine(a.Length.ToString());
}
static void Main(string[] args)
{
Program x = new Program();
x.outdata();
Console.Read();
}
}
public class Data1
{
public int aa;
}
这个程序出错,说是未将对象a引用到实例,为什么我取不到a呢?明明我在main之外声明的对象a
这能说明什么机制啊?谁能帮帮我,我搞不明白!
慕田峪7331174
不负相思意