C
C#2y ago
Kubiszon

❔ .Split function not visible for system

Function .Split invisible for system. Have anybody have the same problem?
21 Replies
Kubiszon
KubiszonOP2y ago
and does anybody know how to solve it?
Kubiszon
KubiszonOP2y ago
hiyosilver
hiyosilver2y ago
The error message is telling you.
Jimmacle
Jimmacle2y ago
this may be a case where using var is making it harder to understand what your code is doing
hiyosilver
hiyosilver2y ago
student is a char, i.e. a single character and as such can't be split.
Kubiszon
KubiszonOP2y ago
but it is reading whole line from file so how can it be char wait i will show all code
Jimmacle
Jimmacle2y ago
clearly result is a string
Kubiszon
KubiszonOP2y ago
Jimmacle
Jimmacle2y ago
what do you expect when you write foreach (var student in result)?
Pobiega
Pobiega2y ago
ReadAllTextAsync gets the entire file as a string, not as string[] (which would be ReadAllLines
Kubiszon
KubiszonOP2y ago
string
hiyosilver
hiyosilver2y ago
@Kubiszon iterating over a string, no matter how long, will give you each individual character one after the other. You need to split it some other way, but it's hart to say how without knowing the format of your input.
Kubiszon
KubiszonOP2y ago
ye i mean at others people it is working hat the funniest thing leeme give you a printscreen
Kubiszon
KubiszonOP2y ago
Pobiega
Pobiega2y ago
thats using ReadAllLines
Kubiszon
KubiszonOP2y ago
ooooh god
Pobiega
Pobiega2y ago
you are using ReadAllText
Kubiszon
KubiszonOP2y ago
damn thank u soo mutch haha
hiyosilver
hiyosilver2y ago
as @Jimmacle suggested, you probably want to get into the habit of using explicit types rather than var, so this doesn't happen (or less often at least).
Kubiszon
KubiszonOP2y ago
thank u all for help
Accord
Accord2y ago
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.
Want results from more Discord servers?
Add your server