I'm new to programming and having a problem with the following code:
private string alphaCoords(Int32 x)
{
char alphaChar;
switch (x)
{
case 0: alphaChar = 'A'; break;
case 1: alphaChar = 'B'; break;
case 2: alphaChar = 'C'; break;
case 3: alphaChar = 'D'; break;
case 4: alphaChar = 'E'; break;
case 5: alphaChar = 'F'; break;
case 6: alphaChar = 'G'; break;
case 7: alphaChar = 'H'; break;
case 8: alphaChar = 'I'; break;
case 9: alphaChar = 'J'; break;
}
return alphaChar.ToString();
}
The compiler says: Use of unassigned local variable 'alphaChar'
But I'm assigning it in my switch block.
I'm sure this is my fault as I dont know enough about programming.
Please advise.
Thanks.