I’m new to F#. I’m using VS2008 shell and F# interactive.
I try to split a string using “System.String.Split” but then I get the error:
“Split is not a static method”
code example:
let Count text =
let words = System.String.Split [' '] text
let nWords = words.Length
(nWords)
How do I use the String methods like split in F# ?
You call them as instance methods:
(Note you need to use
[| |]because Split takes an array not a list; or, as per Joel Mueller’s comment, because Split takes a params array, you can just pass in the delimiters as separate arguments (e.g.text.Split(' ', '\n')).)