[英]C# Syntax error - CS1003 (Generating a CLI)
static void Generations(int value = 50)
{
Console.WriteLine("\tGenerations: {0}", value.ToString());
}
static void Dimensions(int value = 16 16)
{
Console.WriteLine("\tRows: {0}\n\tColumns: {1}", value.ToString());
}
static void Main(string[] args)
Generations();
Dimensions();
Required Output:所需输出:
Generations: 50
Rows: 16
Columns: 16
The error occurs at (int value = 16 16).错误发生在 (int value = 16 16)。 Am I not allowed to pass 2 arguments {0} and {1} in the same one?
我是否不允许在同一个参数中传递 2 个参数 {0} 和 {1}?
You cannot store more than a multiple value in a single object.您不能在单个对象中存储多个值。 What you're looking for is an Array , which is a List in layman's terms.
你要找的是一个Array ,用外行的话说就是一个 List 。
You can define an array by suffixing your type with []
:您可以通过为您的类型添加后缀
[]
来定义数组:
public static int FirstElementOFArray(int[] value) {
return value[0]; //Returns the first element
}
You cannot have a default value for an array, as default values can only be compile-time constants, such as a simple string ( "hello world"
) and numbers ( 11
, 11.5
).数组不能有默认值,因为默认值只能是编译时常量,例如简单的字符串 (
"hello world"
) 和数字 ( 11
, 11.5
)。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.