0

If I have property Keywords which is defined as list of strings

public List<string> Keywords;

I tried with following inline command to assign new list of string

 Keywords =  new List<string>().Add(new List<string>() { "lorem", "ipsum", "root page"})

I know that I can use

List<string> words = new List<string>() { "lorem", "ipsum", "root page"}; 
Keywords = new List<string>().AddRange(words);

but question is how can this be done using inline statement

4

2 回答 2

3
public List<string> Keywords = new List<string>(){"lorem", "ipsum", "root page"};
于 2013-09-17T10:06:39.893 回答
0

不需要Add()List的方法。

  List<string> Keywords = new List<string>(){"lorem", "ipsum", "root page"};
于 2013-09-17T10:27:36.077 回答