Can i use the same variables in several cases without writing them multiple times? e.g.
switch(a)
{
case 1:
ans = string.Format("someString {0}, {1}, {2}", var1, var2, var3);
case 2:
ans = string.Format("anotherString {0}, {1}, {2}", var1, var2, var3);
case 3:
ans = string.Format("thirdString {0}, {1}, {2}", var1, var2, var3);
}
can I write the variables var1, var2 and var3 in one place only? thanks.