RSSCategory: C#



LINQ Select vs SelectMany

Posted by 7 Comments

The best way to explain the difference between Select and SelectMany in Linq is to show an example. In this example we will return a list of courses, each containing a list of students. You will see that Select will return a list of lists of students while SelectMany will flatten the lists into a single list of students.

Continue Reading



Slowing down a loop in .NET

Posted by Leave a Comment

One way to slow down a loop in .NET is to use the System.Threading.Thread.Sleep() method. This will suspend the current thread for a specified amount of time. Note that this is not the same as a timer which fires on the specified interval. The Thread.Sleep method simply pauses that thread for a given amount of time before continuing.

It’s as simple as adding

//Pause current thread for one second before continuing

to the loop you would like to slow down.
Continue Reading