stevendo
August 29th, 2008, 07:54 PM
i have this code
//Array of each function
ArrayList mylist = new ArrayList();
ArrayList mycommands = new ArrayList();
//Divide the file into lines
string[] tokens = myfile.Split(Environment.NewLine.ToCharArray());
foreach (string item in tokens)
mylist.Add(item);
foreach (string command in mylist)
Console.WriteLine(command);
//Divide the lines into commands
foreach (string item in mylist)
{
string[] cmdlst = item.Split(new char[] {';'});
foreach (string command in cmdlst)
{
string newstring = command;
newstring = newstring.Trim();
newstring = newstring.Replace("\r\n", "");
newstring = newstring.Replace("\r", "");
newstring = newstring.Replace("\n", "");
mycommands.Add(newstring);
}
foreach (string command in mycommands)
Console.WriteLine(command);
ok so when it prints out the second time i get a new line for every time i do WriteLine () and then i get an extra new line and i get double spaces in the console.
no matter how hard i try the second time around i cannot get rid of the pesky new lines
any ideas?
.Net framework 3.5
//Array of each function
ArrayList mylist = new ArrayList();
ArrayList mycommands = new ArrayList();
//Divide the file into lines
string[] tokens = myfile.Split(Environment.NewLine.ToCharArray());
foreach (string item in tokens)
mylist.Add(item);
foreach (string command in mylist)
Console.WriteLine(command);
//Divide the lines into commands
foreach (string item in mylist)
{
string[] cmdlst = item.Split(new char[] {';'});
foreach (string command in cmdlst)
{
string newstring = command;
newstring = newstring.Trim();
newstring = newstring.Replace("\r\n", "");
newstring = newstring.Replace("\r", "");
newstring = newstring.Replace("\n", "");
mycommands.Add(newstring);
}
foreach (string command in mycommands)
Console.WriteLine(command);
ok so when it prints out the second time i get a new line for every time i do WriteLine () and then i get an extra new line and i get double spaces in the console.
no matter how hard i try the second time around i cannot get rid of the pesky new lines
any ideas?
.Net framework 3.5