I\'m new to programming and having a problem with the following code:
private string alphaCoords(Int32 x)
{
char alphaChar;
switch (
You need to add a default to your switch statement.
The compiler is stating that there are some cases which will not assign a value to the variable. So adding
default:
alphaChar = 'x'
break;
will tell the compiler "so in case I miss some scenario, make the value this"
or in the case of not wanting to assign a default:
default: throw new Exception();
This is not necessarily better but another way of doing it:
private string alphaCoords(Int32 x)
{
if(x >= 0 && x =< 9)
return ((char)(x + 65)).ToString();
else
throw new ArgumentException();
}