Article Categories
- All Categories
-
Data Structure
-
Networking
-
RDBMS
-
Operating System
-
Java
-
MS Excel
-
iOS
-
HTML
-
CSS
-
Android
-
Python
-
C Programming
-
C++
-
C#
-
MongoDB
-
MySQL
-
Javascript
-
PHP
Selected Reading
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
Advertisements
