Declaring Variables in Visual Basic .NET and C#

Now that you have an understanding of the CLS-compliant data types in .NET, you need to learn how to use these types in your code by declaring variables. You use a declaration statement to define a variable; you also can optionally set a value for the variable when you declare it.


Today, you won't create an application and follow along. You use the code in the listings throughout the day as part of your exercises at the end of the day. If you want to test the code as you're reading, you can create a Windows Forms application and add the various code listings to the code-behind for button click events.

In Visual Basic .NET, using the Dim statement is the simplest way to declare a variable. The ...

Get Sams Teach Yourself Visual Studio® .NET 2003 in 21 Days now with the O’Reilly learning platform.

O’Reilly members experience live online training, plus books, videos, and digital content from nearly 200 publishers.