Skip to main content

Variables in C#

Variables
A variable can be compared to a storage room and is essential for the programmer.
For each variable in C# has a specific type, which determines the size and layout of the variable's memory the range of values that can be stored within that memory and the set of operations that can be applied to the variable.
Variables are initialized with an equal sign followed by constant expression in C#.
<data type> <name>;
The data type must be a valid C# data type including char, int, float, double, or any user-defined data type, and variable name may consist of one or more identifier names separated by commas as shown below.

int x, y, z;

char c, ch;
float f, amount;
double d;

We use the following syntax to define a variable in C#

int  x = 10;
float Float = 1f;
bool Boolean = true;
string Name = "Rohit";
char Char = 'a';
double Double = 5.25;

Apart from this, you can initialize a variable at the time of declaration as shown below.

For Example
int a=10, b=15,c=0;  
c=a+b;
Output =25

Comments

Popular posts from this blog

Media Player in C# Visual Studio By Rohit Programming Zone

Media Player  in C# Visual Studio   Source Code ----------------------------------------------------------------------------------------------------------------------------- using System; using System.Windows.Forms;   namespace Media_Player_in_C_Sharp_By_Rohit_Programming_Zone {     public partial class Form1 : Form     {         public Form1()         {             InitializeComponent();         }         string [] paths, files;           private void btn_open_Click( object sender, EventArgs e)         {             OpenFileDialog ofd = new OpenFileDialog ();   ...

ImageEditor in C# Visual Studio 2017

ImageEditor in C # Start a new project in Visual Studio > choose Visual C# then click on Windows Desktop then select WindowsForm App(.Net Framework)  and name it as ImageEditor then press ok. First, go to the Form1 properties  S ection and set the Size as following. Form1-size=952, 607 Now Add 3 panels from the toolbox and set the properties as follows. After setting the properties it will look as follows. Now Add 2-picture box from the toolbox and go to the properties and set the properties as follows. Now add 15-Button from the toolbox. Now add 3-textbox from the toolbox. Now add 3-trackbar and 5-label from the toolbox. Now go to the properties section and check all the Components are named correctly or not. Once  all the Components are named correctly then  move to the coding part. (Now the Coding Part) Now go to the Form1 code view and  ...

Microsoft tools Download

1-Visual Studio Code Visual Studio Code is a  fast and free  source code lite editor that can be used with the various programming languages. Download 2-Visual Studio 2019 Community Download 3-Microsoft Visual Studio 2010 Microsoft Visual Studio 2010 Development environment specialized in Windows systems. Download 4-VISUAL STUDIO 2013 EXPRESS FOR WEB Visual Studio Express 2013 for Web provides the core tools for creating compelling, innovative web applications and services. This includes the ASP.NET editors for HTML5, CSS3, JavaScript, etc. Download 5-Piskel Download 6-Pichon Download 7-Microsoft XNA Framework Redistributable 4.0 Description The XNA Framework has all the necessary runtime components to execute a game, which was developed using Microsoft XNA Game Studio 4.0. Version 4.0 of the framework contains improved functionality and new features.