+ 1
Working with Strings C#
Hi, i tryed to work with strings for challenges, but i came to a problem. Whenever i tried to use any part of an numeral string as an int (via Convert.ToInt32(string[part]) ) it ended up with 49, 50 and so on, but never with the number it was on the string. You can see it in my Code "Magic Square" (https://code.sololearn.com/cADgEdj4zBm8/#cs) for the Challenge with the same name. Can someone help me fixing it, or better explain my mistake?
2 odpowiedzi
+ 1
instead of Convert.ToInt32(string[part])
use int.Parse(string[part].ToString())
because the Convert method with a character returns an ascii code
0
thanks a lot