i was searching if there's a way to initialize multiple variables with different values on the same line, same as you can do in JavaScript. (maybe in c# 6 ?)
for example:
var x = "hello",
y = "friend";
** EDIT
I know i can assign with the same value (seen other posts on SO as well - i don't see how this post is duplicated ) i would like it to be with different values (using the var key word). as i see from the answers below i see there's no way without explicitly declare the type. so thanks for the help.
just assign like that:
string str = "1", str1="2", str3="3", str4="4", str5="5";
please, remember, that implicitly-typed local variables cannot have multiple declarations so this code will not be compiled:
var someVar1 = "1", someVar2 = "2", someVar3 = "3", someVar4 = "4", someVar5 = "5";//This line is error and is not compiled!
Implicitly-typed variables cannot have multiple declarators. You have to specify the type.
string x = "hello",
y = "friend";
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