Does C# 7 have array/enumerable destructuring?

后端 未结 8 1660
你的背包
你的背包 2020-12-15 15:16

In Javascript ES6, you are able to destructure arrays like this:

const [a,b,...rest] = someArray;

where a is the first element

8条回答
  •  长情又很酷
    2020-12-15 15:52

    Really quick: No.

    C# does not support destructuring for Arrays yet.

    Currently, I cannot find any information of this on the roadmap, either. Seems like there will be a lot of waiting involved until we get this syntactic sugar by default.

    As @Nekeniehl added in the comments, it can be implemented though: gist.github.com/waf/280152ab42aa92a85b79d6dbc812e68a

提交回复
热议问题