Answer the question
In order to leave comments, you need to log in
How to set local variable in switch?
I make a simple design
public int Test(){
string yx1, yx2, yx3;
foreach(KeyValuePair<string, Cell> kv in Cells){
Cell obj = kv.Value;
int x = obj.x;
int y = obj.y;
for(int n = 0; n < 8; ++n){
switch(n){
case 0: yx3 = y+"-"+(x+1); break;
case 1: yx3 = y+"-"+(x-1); break;
..........................................................................
}
Debug.Log(yx3);
..........................................................................
error CS0165: Use of unassigned local variable 'yx3'
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question