Combining array of arrays into single, distinct array using LINQ

后端 未结 1 1432
渐次进展
渐次进展 2020-12-10 06:00

Can this be rewritten any better using LINQ? I\'m a C#er trying to think in VB.NET for this current project. It\'s in an ASP.NET Web Forms .vb codebehind:

Pu         


        
1条回答
  •  半阙折子戏
    2020-12-10 06:34

    You can use SelectMany to flatten such a collection.

    var array = arrayOfArrays.SelectMany(item => item).Distinct().ToArray(); // C#
    Dim array = arrayOfArrays.SelectMany(Function(item) item).Distinct().ToArray() // VB
    

    0 讨论(0)
提交回复
热议问题