✅ System.FormatException: 'Input string was not in a correct format.'
Hello, I am trying to make a Winform Program that takes in a text file, turns it into a string in a generated array textbox, and then sorts the array in another textbox called sort values. However, it seems like I am having some issues parsing my string. Can someone help me here?
Here is the link to my code: https://paste.mod.gg/aarnffywcwsx/0
BlazeBin - aarnffywcwsx
A tool for sharing your source code with the world!
18 Replies
Where exactly is that exception thrown? On the
int[] values = Array.ConvertAll(lines, int.Parse);
?Yes
It means one of the values is not a valid integer, then
Hmmm that’s not right
Should I send my text file or something?
Or a screenshot of what’s going on?
Gimme a sec, I went to sleep after I posted this so I am just seeing all of this now
A bit curious, why would you do that?
Why ask for help as you become available, instead of when you are available?
Almost always, we will have to ask questions to provide help.
Because from my experience it takes a while in order to actually get help
And sometimes the time zones can be very different whenever I ask questions
Whenever I ask these questions it could be in the middle of the night
And I haven’t gotten actual sleep cuz I have been going at a problem so too many hours on my own
I'd say 80-90% of well asked questions get some form of interaction within 30 minutes or so
anyways, show the file
Ok gimme a sec
ok see
look at your code
so we read all lines into an array
then pass each of those lines to
int.Parse
how many lines do you have in that file there?Only one
mhm
and is
,
a valid integer number?No
so.. can you see the issue now? 🙂
Yeah I sort of do
I will see what I can do
Hint:
.Split()
and
File.ReadAllText
Ok I fixed the problem.
Thanks