?
Solved

Problem with String split & foreach loop

Posted on 2007-11-21
4
Medium Priority
?
232 Views
Last Modified: 2010-04-15
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
Comment
Question by:NewMom2Brandon
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 7

Expert Comment

by:lucky_james
ID: 20328048
what is type of arrtext?
0
 
LVL 2

Author Comment

by:NewMom2Brandon
ID: 20328054
ArrayList arrText = new ArrayList();
0
 
LVL 11

Accepted Solution

by:
DotNetThinker earned 500 total points
ID: 20328236
try this...


arrText.AddRange(sLine.ToString().Split((@",").ToCharArray()));
0
 
LVL 2

Author Comment

by:NewMom2Brandon
ID: 20328345
thank you very much..that was it exactly
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

We all know that functional code is the leg that any good program stands on when it comes right down to it, however, if your program lacks a good user interface your product may not have the appeal needed to keep your customers happy. This issue can…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …

719 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question