Delay function in C#

Use an async method to create a delay using the built-in Task.Delay method. This will cause execution to be paused and then resumed after the specified time without blocking the current thread. In your specific case

Best way to randomize an array with .NET

If you’re on .NET 3.5, you can use the following IEnumerable coolness: Edit: and here’s the corresponding VB.NET code: Second edit, in response to remarks that System.Random “isn’t threadsafe” and “only suitable for toy apps” due to returning a time-based sequence: as used in my example, Random() is perfectly thread-safe, unless you’re allowing the routine … Read more

LINQ query on a DataTable

You can’t query against the DataTable‘s Rows collection, since DataRowCollection doesn’t implement IEnumerable<T>. You need to use the AsEnumerable() extension for DataTable. Like so: And as @Keith says, you’ll need to add a reference to System.Data.DataSetExtensions AsEnumerable() returns IEnumerable<DataRow>. If you need to convert IEnumerable<DataRow> to a DataTable, use the CopyToDataTable() extension. Below is query with Lambda Expression,

What is the easiest way to encrypt a password when I save it to the registry?

You don’t decrypt authentication passwords! Hash them using something like the SHA256 provider and when you have to challenge, hash the input from the user and see if the two hashes match. Leaving passwords reversible is a really horrible model. Edit2: I thought we were just talking about front-line authentication. Sure there are cases where you want … Read more