C
Join ServerC#
help
Hexadecimal format specifier not working
00x3F11/2/2022
for(int X = 1 ; X <= 5 ; X++)
{
var F = Math.Pow(63, X);
Console.WriteLine($"{F:X}");
}
For some reason this is not working and I receive an error: FormatException: Format specifier was invalid.00x3F11/2/2022
And even if I try
F.ToString("X")
it's also not workingMmtreit11/2/2022
It's because your variable
F
is a floating point number. It needs to be an integer.Mmtreit11/2/2022
Also don't use capital letters for variable names.
00x3F11/2/2022
Okay, that worked! I didn't know it works only for integers, thanks!