C
C#4mo ago
Mathall

2d char array is not showing the 1 character

Hey all, im trying to make a console based minesweeper game, and i have a function that detects how many mines are around a given tile,
C#
if(surroundingMineCount > 0)
{
BoardArr[x,y] = Convert.ToChar(surroundingMineCount);
}
C#
if(surroundingMineCount > 0)
{
BoardArr[x,y] = Convert.ToChar(surroundingMineCount);
}
and I thought this was working well until, it realized it was showing whitespace(the blank tiles) when written to the console,. yet when I check the debug values (below image), it does show its value is 1 or 2 or however many mines, but its character code is not that same value Any help would be greatly appreciated!
No description
6 Replies
substitute
substitute4mo ago
How are you writing the value? "1" is not the same as 1
substitute
substitute4mo ago
No description
substitute
substitute4mo ago
Actually, I see it ToChar
public static char ToChar(int value) => ToChar((uint)value);
public static char ToChar(int value) => ToChar((uint)value);
it doesn't convert it to the unicode value it just casts the value to char
Mathall
MathallOP4mo ago
Well fir the non number I have i do the same thing But instead of numbers it is either white space or X's for mines Oh i see what you mena
substitute
substitute4mo ago
if you will only ever have 1 character wide counts, you can use
BoardArr[x,y] = surroundingMineCount.ToString()[0]
BoardArr[x,y] = surroundingMineCount.ToString()[0]
Mathall
MathallOP4mo ago
Ohh, thats a great thing yes, thank you, the max is going to be 8
Want results from more Discord servers?
Add your server