Locations of visitors to this page


Use Linq to create a random list of numbers

Onteora Software

Ken Tucker's Blog

About the author

Author Name is someone.
E-mail me Send mail

Recent posts

Recent comments

Disclaimer

The opinions expressed herein are my own personal opinions and do not represent my employer's view in anyway.

© Copyright 2008

Use Linq to create a random list of numbers

Here is a simple linq query which places the numbers from 1 and 150 in a random order

 

Dim r As New Random(Now.Ticks Mod Int32.MaxValue)

Dim rndLst = From l In (From num In Enumerable.Range(1, 150) _
             Select New With {.Num = num, .pos = r.Next(1, 150)}) _
             Order By l.pos _
             Select l.Num

For Each i In rndLst
    Console.WriteLine(i)
Next


kick it on DotNetKicks.com

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Categories: Linq | VB | VS 2008
Posted by Ken Tucker on Monday, December 03, 2007 2:14 PM
Permalink | Comments (1) | Post RSSRSS comment feed

Related posts

Comments

required

Wednesday, August 27, 2008 12:45 AM

required

cbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb sdf sdfasdf

Add comment


(Will show your Gravatar icon)  

  Country flag

[b][/b] - [i][/i] - [u][/u]- [quote][/quote]



Live preview

Thursday, September 04, 2008 8:50 PM