I am new to programming, and this is my first time working with a .NET language, so I apologise in advance if this question sounds really stupid/trivial.
Here are the relevant snippets of my code:
let isInteger (element: string) =
let success, result = Int32.TryParse(element)
if success then Some(result)
else None
let removeUnnecessaryInfo (someString: string) =
if isInteger someString.[-1] <> None then
someString.Remove(-2, 2)
else
someString.Remove(-1, 1)
However, when I try to run it in F# Interactive, I received the following message:
"DuplicateFileFinder.fsx(15,22): error FS0001: This expression was expected to have type string
but here has type char
I.e., "someString.[-1]" is classified as having the type char, which is why isInteger someString.[-1] fails.
Please give me some tips on the changes I can make to get the code to work. Thank you in advance!