C#: Assign same value to multiple variables in single statement

后端 未结 11 1240
甜味超标
甜味超标 2020-12-01 00:13

Is there any way (just out of curiosity because I came across multiple same-value assignments to multiple variables today) in C# to assign one value to multiple variables at

11条回答
  •  盖世英雄少女心
    2020-12-01 00:32

    This is now a thing in C#:

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

    By doing the above, you have basically declared three variables. a = 1, b = 2 and c = 3. All in a single line.

提交回复
热议问题