In perl I can define a bunch of variables in 1 line:
my value=0;
my (a,b,c)=value;
is there some similar C# way of doing the same? here is what I have:
const bool free = true;
bool t1,t2,t3;
private void Form1_Load(object sender, EventArgs e) {
//t1,t2,t3=free;
}
I believe you can do t1 = t2 = t3 = free; However, it really makes it much harder to read. I would not recommend it.
C# does not support full destructuring assignment. Thus, there is no C# equivalent of
my @v = (1,3,5);
my ($a,$b,$c) = @v;
However, as pointed out by @Guthwulf, in the case of a scalar you can write t1 = t2 = t3 = free and it will assign the same value to each element.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With