C
C#5mo 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
substitute5mo ago
How are you writing the value? "1" is not the same as 1
substitute
substitute5mo ago
No description
substitute
substitute5mo 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
MathallOP5mo 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
substitute5mo 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
MathallOP5mo 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