我直接有一个非常简单的程序,从我的教科书,是为了打印您键入命令行的话名称的列表。
当我尝试运行代码,我得到一条错误...
“错误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 - 使用开发提示”。)
任何帮助是极大的赞赏!
Length
是一个属性。属性都写在帕斯卡情况。看起来你只是在你的第二个Console.WriteLine
一个错字。有一个小写L的args.length。
Console.WriteLine( “在命令行中:” “您输入以下{0}名称” +,args.Length);它应该是长