Tip Bank

DevX - Software Development Resource

Understanding passing arrays by reference

.NET arrays are object types, thus an array variable is actually a pointer to the object where data is actually stored. For this reason, when you pass an array to

DevX - Software Development Resource

Take advantage of the new math functions

The System.Math class exposes several static methods that let you perform many common operations. These functions replace the VB6 functions with same name, but there are a few new functions

DevX - Software Development Resource

Write applications that take arguments

C# has a nice feature that VB.NET lacks: the ability to define a Main procedure that takes an array of strings, each one containig one of the arguments passed on

DevX - Software Development Resource

Create console apps that return an exit code

Writing an application that returns an ERRORLEVEL to Dos is quite difficult in VB6, because you are forced to use a Windows API that ends the application immediately, thus preventing

DevX - Software Development Resource

Create a command-line filter utility

The Console class exposes two properties that make it very simple to create command-line utilities that work as filters, exactly like the FIND and MORE utilities that are provided with

DevX - Software Development Resource

Duplicate the SET operating system command

The Environment.GetEnvironmentVariables property returns the list of all the environment variables, as an IDictionary object. If you want to display them sorted by their name, as the SET command does

DevX - Software Development Resource

Retrieving special system paths

The GetFolderPath method of the Environment class lets you retrieve the path of several important system directories. For example, here’s how you determine the path of the Desktop directory for

DevX - Software Development Resource

Retrieve Windows and System directories

In VB.NET you don’t need to call the GetWindowsDirectory and GetSystemDirectory API functions to retrieve the path the Windows and System directories. Retrieving the System directory is as simple as