
- C# Basic Tutorial
- C# - Home
- C# - Overview
- C# - Environment
- C# - Program Structure
- C# - Basic Syntax
- C# - Data Types
- C# - Type Conversion
- C# - Variables
- C# - Constants
- C# - Operators
- C# - Decision Making
- C# - Loops
- C# - Encapsulation
- C# - Methods
- C# - Nullables
- C# - Arrays
- C# - Strings
- C# - Structure
- C# - Enums
- C# - Classes
- C# - Inheritance
- C# - Polymorphism
- C# - Operator Overloading
- C# - Interfaces
- C# - Namespaces
- C# - Preprocessor Directives
- C# - Regular Expressions
- C# - Exception Handling
- C# - File I/O
- C# Advanced Tutorial
- C# - Attributes
- C# - Reflection
- C# - Properties
- C# - Indexers
- C# - Delegates
- C# - Events
- C# - Collections
- C# - Generics
- C# - Anonymous Methods
- C# - Unsafe Codes
- C# - Multithreading
- C# Useful Resources
- C# - Questions and Answers
- C# - Quick Guide
- C# - Useful Resources
- C# - Discussion
How to declare variables in C#?
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.
To declare variables −
<data_type> <variable_list>;
Let us see an example to declare two integer variables −
int a, b;
Above the variable is of int type. Let us declare a variable for other types −
Variable of float type.
float f;
Variable of double type.
double d;
Let us display a variable −
Example
using System; using System.Collections; class Demo { static void Main() { int x = 50; Console.WriteLine("Integer variable:"+x); } }
Output
Integer variable:50
- Related Articles
- How to declare variables in JavaScript?
- How to declare global Variables in JavaScript?
- How to declare String Variables in JavaScript?
- How to declare boolean variables in JavaScript?
- How to declare global variables in Android?
- How to declare an Array Variables in Java?
- How to declare Block-Scoped Variables in JavaScript?
- What are the rules to declare variables in C++?
- How do I declare global variables on Android?
- How to use the Properties file to declare global variables in a framework in Selenium?
- How to declare a variable in C++?
- How to declare an array in C#?
- How to declare an event in C#?
- How to declare a delegate in C#?
- How to declare a tuple in C#?

Advertisements