asp.net.ph

Skip Navigation LinksHome > Getting Started > ASP.NET Programming Languages Primer > Variable Declarations and Initialization

ASP.NET Programming Languages Primer


Variables represent name=value entries in memory. You can think of variables as named objects that you define, for which you can assign values, that you can later use and modify.

A variable must be declared before you can use it. This initially sets the variable’s name and type in memory. The type determines what values can be stored in the variable ( ex. strings, integers, dates, etc. ).

// String
string productName;

// Integer
int totalItems;

// Boolean
bool hasImage;

// Date and Time
DateTime releaseDate;
  C# VB JScript

NOTE: The type identifier must conform to the data types supported by the language. The .NET Framework is a type-safe environment, meaning each of the language compilers guarantee that values stored in variables are always of the correct type.

A variable can be assigned an initial value when it is declared.

// String
string productName = "Harry Potter and The Chamber of Secrets ( Widescreen Edition ) ";

// Integer
int totalItems = 5;

// Boolean
bool hasImage = false;

// Date and Time
DateTime releaseDate = DateTime.Now;
  C# VB JScript

The value of a variable can be changed through assignment or through the use of operators appropriate to the language.

 Show me 

More ...
Back to top


© 2025 Reynald Nuñez and asp.net.ph. All rights reserved.

If you have any question, comment or suggestion
about this site, please send us a note