Combining array of arrays into single, distinct array using LINQ

后端 未结 1 1430
渐次进展
渐次进展 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)
提交回复
热议问题