- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
C# Multiple Local Variable Declarations
In C#, you can use the comma to declare more than one local variable in a statement. The following displays the same −
int a = 20, b = 70, c = 40, d = 90;
Example
Let us see an example in which we are declaring multiple local variables. Below four variable is declared and initialized in the same statement.
using System; class Demo { static void Main() { int a = 20, b = 70, c = 40, d = 90; Console.WriteLine("{0} {1} {2} {3}", a, b, c, d); } }
Output
20 70 40 90
- Related Articles
- final local variable in Java
- Difference between static, auto, global and local variable in C++
- Difference Between Local and Global Variable
- Print Single and Multiple variable in C#
- Array Declarations in C#
- How to declare a local variable in Java?
- How to access a local variable from a different function using C++ pointers?
- Can a local variable's memory be accessed outside its scope in C/C++?
- Local Variable Type Inference or LVTI in Java 10
- How to assign multiple values to same variable in C#?
- What are forward declarations in C++?
- What is typedef declarations in C++?
- Initialization of local variable in a conditional block in Java
- What is the default value of a local variable in Java?
- How to import local json file data to my JavaScript variable?

Advertisements