I'm trying to save the score of a player, like this for example: 380/500, and so I created this line of code: Un_Levels.S_Level_1 = intScore.ToString() + "/" + maxScore.ToString();.
I'm not sure why, but the "/" throws me an error "Input string was not in a correct format" when the function is called.
Can someone help me with this one please?
#Problem with string variable
1 messages · Page 1 of 1 (latest)
Don't ever save multiple values in the same field.
And you usually also don't want to save numbers as strings; converting strings to other formats is expensive.
That being said, without knowing the code that throws the error you show, it's not possible to solve your problem.
And speaking of code, you shouldn't use underscores in names in C#.
Okay, I see what you mean.
That will be quite some changes to my code, but that's okay.
I have one question though, why shouldn't I use underscores?
Although technically nothing will stop you, it's unconventional to do so.
Naming convention in C# is to use PascalCase for public members, type names and methods, and camelCase for private members, parameters and locals.
Occasionally, you will see private fields prefixed with underscores but beyond that, underscores are not usually used.
In keeping with established conventions, you will make your code easier to read & understand for others.
Makes sense I suppose, I will keep that in mind.
Well then, thank you very much for your help kind person!