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");
VulpesPosted Jan 3, 2013, 1:45 PM
foreach (string subString in TextReplyTrim.Split('\n'))
{
string temp = subString;
if (subString.Contains("/qs"))
{
temp = temp.Replace("/qs", " "); // replace with space
}
TextReplySave += temp + " ";
}
Note, that since you can't change the foreach control variable, subString, directly you need to use a copy.
Glenn PattonPosted Jan 4, 2013, 4:15 AM