using System;
using System.IO;
using System.Text;
public class Movies
{
public string moviename { get; set; }
public int cast { get; set; }
public string[] castmember { get; set; }
public override string ToString()
{
return string.Format("Movie: {0} \nCast #: {1} \nCast Member: {3}",
moviename.ToString(),
cast,
castmember.ToString());
}
}
public class MovieData
{
public int NumberOfLines = 0;
public string UserInput;
public void ManageData()
{
string[] text = File.ReadAllLines("@File Path");
NumberOfLines = text.GetUpperBound(0);
Movies[] movies = new Movies[NumberOfLines];
int i = 0;
foreach (string line in text)
{
movies[i] = new Movies();
movies[i].moviename = Convert.ToString(line.Trim());
movies[i].cast = Convert.ToInt32(line.Trim());
int ii = movies[i].cast;
//Here I want to create a movies[i].castmember[ii] with ii being the length
}
我正在尝试存储基本上以行格式的数据,但是有一组特定的行将更合乎逻辑地存储在数组中。我将如何创建一个长度为 ii (cast) 的 movies[i].castmember 数组?