Assign the same value to multiple variables in a single statement

Md Asif AlamMd Asif Alam
1 min read

Table of contents

You might be seen this statement previously where we assign a single value to multiple variables,

int num1, num2, num3;

num1 = num2 = num3 = 5;

But within C# we can assign multiples values to multiple variables using the statement

var (a, b, c) = (1, 2, 3);

By doing this, we have got

a = 1, b = 2, c = 3
0
Subscribe to my newsletter

Read articles from Md Asif Alam directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

Md Asif Alam
Md Asif Alam

๐Ÿš€ Full Stack .NET Developer & React Enthusiast ๐Ÿ‘จโ€๐Ÿ’ป About Me: With 3+ years of experience, I'm passionate about crafting robust solutions and seamless user experiences through code. ๐Ÿ’ผ Expertise: Proficient in .NET Core API, ASP.NET MVC, React.js, and SQL. Skilled in backend architecture, RESTful APIs, and frontend development. ๐ŸŒŸ Achievements: Led projects enhancing scalability by 50%, delivered ahead of schedule, and contributed to open-source initiatives. ๐Ÿ” Future Focus: Eager to embrace new technologies and drive innovation in software development. ๐Ÿ“ซ Let's Connect: Open to new opportunities and collaborations. Reach me on LinkedIn or GitHub!