Initializing list inline

前端 未结 4 406
没有蜡笔的小新
没有蜡笔的小新 2020-12-10 00:26

I\'m getting a weird error when doing this: (.net 2.0)

public overrides List getSpaceballs
{
    get { return new List() { \"abc\         


        
4条回答
  •  生来不讨喜
    2020-12-10 01:01

    Just in case anyone would search for it as well nowadays, there is a neat way to do that using LINQ extensions. Hope it helps someone ;)

    var list = new string[]{ "1", "2", "3" }.ToList();
    

提交回复
热议问题