-3
我最终想测试一些随机性的字符串。开始我想我需要制作一种方法,可以读取位串的文本文件并将它们存储在数组中。如何从文本文件中获取一些位串并将它们放入数组中?
private static int[] ReadDataFile(string s)
{
List<int> theList = new List<int>();
string[] sArray;
string bs;
StreamReader inputfile = new StreamReader("bitstring.txt");
do
{
bs = inputfile.ReadLine();
sArray = bs.Split(new char[] { });
for (int i = 0; i < sArray.Length; i++)
{
theList.Add(int.Parse(sArray[i]));
Console.WriteLine(sArray[i]);
}
} while (inputfile.EndOfStream);
inputfile.Close();
return theList.ToArray;
}
我在最后一行写着
无法转换methid组ToArray的非委托类型为int []得到一个错误。
我该如何解决?这是正确的方法吗?
有多大是你的文件,你看?你的文件结构如何?这有助于回答你最后的问题 –