Is there a way to do this:
valueType x = 1, y = 1, z = 1;
with less characters?
e.g. When I have a large amount of state to initialize to the same starting value.
Thanks!
You could try
int x, y, z;
x = y = z = 1;
But I can't see how it would help you... if you have really lots of variables you must initialize to the same thing, you could consider using some kind of collection:
var myInts = new List<int>();
for (int i = 0; i < 1000; i++)
myInts.Add(1);
If the starting value is zero and they are members of your class (not local variables) then you don't need to explicitly initialize them to zero.
Otherwise, no.
Would it make sense to use arrays instead of having a large number of parameters?
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