Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/306.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# System.Array不包含';拆分';_C#_System.array - Fatal编程技术网

C# System.Array不包含';拆分';

C# System.Array不包含';拆分';,c#,system.array,C#,System.array,我正试着把一根绳子分开。但是,每当我使用fullName.SplitVisualStudio时,都会说System.Array不包含Split的定义 这是我到目前为止的主要方法 public static void Main(string[] args) { string inValue; int noNames; string[] names = new string[100]; // find number of n

我正试着把一根绳子分开。但是,每当我使用
fullName.Split
VisualStudio时,都会说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
        }
    }
publicstaticvoidmain(字符串[]args)
{
字符串无效;
非整数非整数;
字符串[]名称=新字符串[100];
//查找名称的数目
Console.WriteLine(“输入名称的数量:”);
inValue=Console.ReadLine();
内锥虫(无效,外锥虫);
字符串[]全名=新字符串[非名称];
for(int i=0;i

奇怪的是,在此之前不久,我能够编写另一个使用Split方法的程序。这个计划没有问题。我不确定我的代码是否有问题,或者Visual Studio是否有错误。有人能帮我解决这个错误吗?如果这很重要,程序还没有完成。

您需要在数组的元素上调用它,而不是数组本身。。因此,这将是:


string[]name=fullName[i]。拆分(“”)

您正在尝试拆分数组,而不是字符串。不能使用特定的字符(如字符串)以这种方式拆分数组

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[i].Split(' '); //error appears here
        }
    }
publicstaticvoidmain(字符串[]args)
{
字符串无效;
非整数非整数;
字符串[]名称=新字符串[100];
//查找名称的数目
Console.WriteLine(“输入名称的数量:”);
inValue=Console.ReadLine();
内锥虫(无效,外锥虫);
字符串[]全名=新字符串[非名称];
for(int i=0;i
您使用的是什么版本的.NET framework?我使用的是4.0,之前的研究表明我可能没有使用正确的.NET framework。谢天谢地我有这个。哇。。。这么简单。我不敢相信我忽略了这一点。非常感谢。非常感谢您的指导!我没想到会有这么快的反应。每个花时间回答这些问题的人都很棒。是的,我只是错过了价值。非常感谢您抽出时间回答我的问题。@user1729696如果这回答了您的问题,请按此标记