我正在尝试获取一个字符串并将其拆分。但是,每当我使用fullName.Split
Visual Studio 时,都会说 System.Array 不包含 Split 的定义。
到目前为止,这是我的主要方法。
public static void Main(string[] args)
{
string inValue;
int noNames;
string[] names = new string[100];
// find number of names
Console.WriteLine("Enter the number of names: ");
inValue = Console.ReadLine();
int.TryParse(inValue, out noNames);
string[] fullName = new string[noNames];
for (int i = 0; i < fullName.Length; i++)
{
string[] name = fullName.Split(' '); //error appears here
}
}
奇怪的是,在此之前不久,我能够编写另一个使用 Split 方法的程序。该程序没有问题。我不确定我的代码是否有问题,或者 Visual Studio 是否有错误。谁能帮我解决这个错误?该程序不完整,如果这很重要的话。