c# switch problem

后端 未结 8 2356
囚心锁ツ
囚心锁ツ 2020-12-03 18:53

I\'m new to programming and having a problem with the following code:

    private string alphaCoords(Int32 x)
    {
        char alphaChar;

        switch (         


        
8条回答
  •  鱼传尺愫
    2020-12-03 18:59

    After you declare the variable char alphaChar, you should "assign" a value to it (set it to be equal to something), even though you expect it to get a value in the switch statement.

    You could assign it 'A' or '0' or pretty much anything.

    You can do that in the declaration like this

    char alphaChar = 'A';
    

    Or you can do it separately

    char alphaChar;    
    alphaChar = 'A';
    

提交回复
热议问题