我对 C# 真的很陌生。我有多个计算机实例,每个实例都有一个与每个实例关联的名称、停止、启动和重新启动命令。我想从文件中读取信息。
所以我想以instancelist[0].Instance_name=Enterprise1
和instancelist[0].Instance_stop=@Enterprise_stop
等等结束instancelist[1].Instance_name=Enterprise5
。我可以弄清楚如何进行声明。
public class Instance
{
public string Instance_name;
public string Instance_stop;
public string Instance_restart;
public string Instance_backup;
}
public static void Main(string[] args)
{
int num_instances=0;
/** CAN'T figure out the declaration. I'm currently thinking array of array? */
System.IO.StreamReader file = new System.IO.StreamReader(@"C......");
while(true)
{
instancelist[num_instance].Instance_name=file.ReadLine();
instancelist[num_instance].Instance_stop=file.ReadLine();
// and so on.......
num_instance++;
}
}