 
  Data Structure Data Structure
 Networking Networking
 RDBMS RDBMS
 Operating System Operating System
 Java Java
 MS Excel MS Excel
 iOS iOS
 HTML HTML
 CSS CSS
 Android Android
 Python Python
 C Programming C Programming
 C++ C++
 C# C#
 MongoDB MongoDB
 MySQL MySQL
 Javascript Javascript
 PHP PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How to assign same value to multiple variables in single statement in C#?
To assign same value to multiple variables in a single line, use the = operator −
val1 = val2 = 20;
The above statement assigns 20 to the variables val1 and val2 as shown in the following code −
Example
using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace Demo {    class MyApplication {       static void Main(string[] args) {          int val1, val2;          val1 = val2 = 20;          Console.WriteLine("Value1 = "+val1);          Console.WriteLine("Value2 = "+val2);       }    } }  Output
Value1 = 20 Value2 = 20
Advertisements
 