Glenn Patton

Glenn Patton

  • NA
  • 308
  • 82.9k

How can I get rid of charters in a foreach loop

Jan 3 2013 12:21 PM
Hi All,

I am using a foreach loop to break up a string as follows 

foreach (string subString in TextReplyTrim.Split('\n'))

this gives me all data split up into the string  subString  I have used this many times and it works.  subString is added to the string

TextReplySave += subString + ' '; I have found by checking substring some times a bit of corrupt data is in the string typically  "/qs" if I chop out the '/'  in the date (03/01/2013) etc so what would be the correct way I can trap it  with the below:

if (subString.Contains("/qs"))

{

//throw ????

}

If I can trap it I was thinking make it equal to a space (=' ';) but that does not seem to be allowed. Any ideas anyone?

(Happy New Year, if it's your new year!)

Glenn

        MessageBox.Show("error");

Answers (2)