为什么我的C#程序无法识别的长度?

问题描述 投票:0回答:2

我直接有一个非常简单的程序,从我的教科书,是为了打印您键入命令行的话名称的列表。

当我尝试运行代码,我得到一条错误...

“错误CS1061:‘串[]’不包含‘长度’和没有可访问的扩展方法‘长度’接受类型的第一个参数定义‘字符串[]’可以找到(是否缺少使用指令或程序集参考?)”

注:我不是通过Microsoft Visual Studio中运行,是因为转让涉及通过一个文本编辑器中运行的代码。

代码在这里:

// Hello World2.cs
using System;

public class HelloWorld2
{
    public static void Main(string[] args)
    {
        Console.WriteLine("Hello, World.");
        Console.WriteLine("You entered the following {0} names " +
            "on the command line:", args.length );
        for (int i=0; i < args.Length; i++)
        {
            Console.WriteLine("{0}", args[i]);
        }
            Console.ReadKey(true);
    }
}

链接到程序分配here

(中途向下滚动网页,分配称号后开始“HelloWorld2 - 使用开发提示”。)

任何帮助是极大的赞赏!

c# arrays compiler-errors string-length
2个回答
0
投票

Length是一个属性。属性都写在帕斯卡情况。看起来你只是在你的第二个Console.WriteLine一个错字。有一个小写L的args.length。


0
投票

Console.WriteLine( “在命令行中:” “您输入以下{0}名称” +,args.Length);它应该是长

© www.soinside.com 2019 - 2024. All rights reserved.