❔ input string is not correct format
Context: I was playing around the advent-of-code posted by someone else, a line of his code kept giving me this error
ìnput string is not correct format
I tried tryparse etc but to no avail. The precise error position is at line 15 the full code is here: https://github.com/bradwilson/advent-2022/blob/main/day15/Program.cs
I read a lot of SO posts about the input not converted to int (which triggered the error)
, but here he uses so would it be enough for the input to be parsed int? (this is my uneducated guess)GitHub
advent-2022/Program.cs at main · bradwilson/advent-2022
Advent of Code 2022 (C# 11/.NET 7). Contribute to bradwilson/advent-2022 development by creating an account on GitHub.
6 Replies
data[0] is the entire first line of the input file
you can do
Console.WriteLine(data[0]);
before the Parse to see itMore specifically, that exception occurs whenever you try to parse a string which cannot be parsed for one reason or another.
thinker227#5176
REPL Result: Failure
Exception: FormatException
Compile: 427.780ms | Execution: 27.529ms | React with ❌ to remove this embed.
Was this issue resolved? If so, run
/close
- otherwise I will mark this as stale and this post will be archived until there is new activity.Oh yes, I confirmed that by doing . My uneducated guess is now that I need to parse the entire input of the
var data
then? If so, could you kindly give me some hints to parse the entire var, not just the first line [0]
?
🤦Was this issue resolved? If so, run
/close
- otherwise I will mark this as stale and this post will be archived until there is new activity.