Variables are named entities used to store data.
Variables are used to store data.
The name of a variable must begin with an alphabetic character and cannot contain whitespace or reserved characters.
A variable can be of a specific type, indicating the kind of data it stores. String variables store string values ("Welcome to mytat"), integer variables store number values (103), date variables store date values, etc.
Variables are declared using the var keyword, or by using the type (if you want to declare the type), but ASP.NET can usually determine data types automatically.
Examples
// Using the var keyword:
var greeting = "Welcome to mytat";
var counter = 103;
var today = DateTime.Today;
// Using data types:
string greeting = "Welcome to mytat";
int counter = 103;
DateTime today = DateTime.Today;
var greeting = "Welcome to mytat";
var counter = 103;
var today = DateTime.Today;
// Using data types:
string greeting = "Welcome to mytat";
int counter = 103;
DateTime today = DateTime.Today;
Practice Excercise Practice now