Random array using LINQ and C#

后端 未结 6 1474
北恋
北恋 2020-12-02 00:10

I was reading an article on MSDN Magazine about using the Enumerable class in LINQ to generate a random array. The article uses VB.NET and I\'m not immediately sure what the

6条回答
  •  时光取名叫无心
    2020-12-02 00:32

    The Developer Fusion VB.Net to C# converter says that the equivalent C# code is:

    System.Random rnd = new System.Random();
    IEnumerable numbers = Enumerable.Range(1, 100).OrderBy(r => rnd.Next());
    

    For future reference, they also have a C# to VB.Net converter. There are several other tools available for this as well.

提交回复
热议问题