I have a question… i am trying to get the 3 words that appear most in a string. this is what i have
strng = “i am to go up i am to go down i am coming up to reach the highest point "
ListOfWords = strng.Split(” ").GroupBy(Function(w) w).OrderByDescending(Function(g) g.Count())
but the work flow keeps displaying the error - "option strict on disallows implicit conversions from “string” to “char”
strng.Split(” ")
You need to use a character when splitting text, because the quotes sees it as a string.
So to do that you can simply use “c” next to it or “(0)” to take the first character. strng.Split(" "c) strng.Split(" "(0)) strng.Split({" "}, System.StringSplitOptions.RemoveEmptyEntries)
The last option works for strings by converting it to a character array, and you can use SplitOptions with it.
This will fix the “…from string to char” erorr you got.
As for the rest of your code, it looks right but I’m not sure.
Thanks for the reply but i dont seem to fully understand your explanation - first i am trying to split the string into an array of strings like so - {“i”,“am”,“to”,“go”,“up”,“i”,“am”, etc} how can i achieve this?
wow thanks didnt know there was such activity. Also i attached a screenshot to this message, i’m wondering why it still gives an error. the list of strings is stored in ListOfWords and i assigned it to this ListOfWords.GroupBy(Function(w) w).OrderByDescending(Function(g) g.Count()), trying to get the words that appear most. What could i be doing wrong?
Error Says it very clearly, your Linq is returning a value of type IOrderedEnumerable(grouping(String)) and you are trying to assign that to String, this is issue with TypeCasting.