C# Variables

In this lesson, learn how to work with C# Variables. Variables in Java are reserved areas allocated in memory. It is a container that holds value. Each variable is assigned a type, which is known as data type.

The reserved area set for the variable marks is shown below. The variable is assigned a value of 95. Also, you can see, we need a data type to declare a variable. The int data type is used below:

Csharp Variables

Declare a variable

To declare a variable in C#, mention the datatype followed by the variables i.e.

The above syntax displays that it is so easy to declare variables, for example,

Initialize Variables in C#

To initialize a variable in C#, assign a value to it. Here are some examples:

Variables – Example

Let us now see a complete example for C# variables and print them:

Output

C# Type Casting
C# Introduction
Studyopedia Editorial Staff
contact@studyopedia.com

We work to create programming tutorials for all.

No Comments

Post A Comment

Discover more from Studyopedia

Subscribe now to keep reading and get access to the full archive.

Continue reading