Initializing list inline

前端 未结 4 399
没有蜡笔的小新
没有蜡笔的小新 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 00:47

    As the other users point out, that is not supported in 2.0. However, you can mimic it by doing the following.

    public overrides List getSpaceballs
    {
       get { return new List ( new String[] {"abc","def","egh"} ); }
    }
    

    Please note that this creates some computational overhead.

提交回复
热议问题