Variables

Variables are storage locations and in C# must have a specific type. When declared within method, property, or indexer declarations, variables are said to be local. Variables are declared in the following way:

					type variablename;
				

To create an integer variable, we would write the following:

int x;

Variables must be assigned a value before they can be used, and we can both declare and assign a value to a variable in one step:

int x = 1;

Get ASP.NET by Example now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.