Problem with String split & foreach loop

I have a string that is being read in from a file.
application.exe,pathofapplication

what I need to do is only add the app.exe to my arraylist. I am getting a casting error (Unable to cast object of type 'System.String[]' to type 'System.String') on my foreach loop

What do I need to do to fix this?

arrText.Add(sLine.ToString().Split((@",").ToCharArray()));

foreach (string mystring in arrText)
{
}
LVL 2
NewMom2BrandonAsked:
Who is Participating?
 
DotNetThinkerCommented:
try this...


arrText.AddRange(sLine.ToString().Split((@",").ToCharArray()));
0
 
lucky_jamesCommented:
what is type of arrtext?
0
 
NewMom2BrandonAuthor Commented:
ArrayList arrText = new ArrayList();
0
 
NewMom2BrandonAuthor Commented:
thank you very much..that was it exactly
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.