August 10, 2002

Create zero-elements arrays

The .NET framework lets you create two types of “empty” arrays: unitialized arrays and arrays that are initialized with zero elements. Uninitialized arrays are actually array variables that are set to Nothing, whereas zero-element arrays are non-Nothing variables that point to arrays with zero elements. Here is the (undocumented) method

Control what happens when an unhandled exception occurs

By default, when an unhandled exception occurs in a managed application, a dialog box appears that asks you whether you want to debug the application with one of the debuggers that are listed in a listbox. (Notice that Windows Forms applications display a different dialog box.)The behavior of the .NET

A For Each loop that iterates in reverse order

The For Each loop always iterates orderly on all the elements of an array or a collection (more precisely, on all the elements of a class that implements the IEnumerable interface). What happens if you need to iterate in reverse order, though? If you have an array or an ArrayList

A For Each statement that visits items in random order

At times you may need to process elements of an array, a collection, or a dictionary object in random order, for example when sampling a population or (more often) when writing a game, such as a card game. Here’s a class that you can use in a For Each statement

A generic benchmark routine

You often need to benchmark a piece of code, which you usually do as follows: Dim start As Date = Now’ insert here the code to benchmarkDim elapsed As TimeSpan = Now.Subtract(start)Console.WriteLine(“Total time: {0} secs.”, elapsed) Thanks to delegates, you can write a reusable routine that can benchmark any Sub