som*_*ing 0 c# constructor compiler-errors list
我正在学习C和C#,这个问题适用于C#.这个问题是书中的代码,代码不能编译,错误是:错误CS1729:类型System.Collections.Generic.List<string>' does not contain a constructor that takes5'参数.
这是代码:
public static void Main (string[] args)
{
List<string> names = new List<string>("Christa ",
" Sarah",
"Jonathan",
"Sam",
" Schmekowitz");
Run Code Online (Sandbox Code Playgroud)
改变(和)到{和}.
即
List<string> names = new List<string>{"Christa ",
" Sarah",
"Jonathan",
"Sam",
" Schmekowitz"};
Run Code Online (Sandbox Code Playgroud)