Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 235
  • Last Modified:

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)
{
}
0
NewMom2Brandon
Asked:
NewMom2Brandon
  • 2
1 Solution
 
lucky_jamesCommented:
what is type of arrtext?
0
 
NewMom2BrandonAuthor Commented:
ArrayList arrText = new ArrayList();
0
 
DotNetThinkerCommented:
try this...


arrText.AddRange(sLine.ToString().Split((@",").ToCharArray()));
0
 
NewMom2BrandonAuthor Commented:
thank you very much..that was it exactly
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now