The logic I’m trying to use is this:
1. Look at the last element of the List
2. If it is a new line (carriage return), delete it
int stringLength = mailingList.Count;
if (mailingList[stringLength - 1].Equals(Environment.NewLine))
{
//mailingList.RemoveAt(stringLength - 1);
txtOutput.Text = "exists";
}
else
{
txtOutput.Text = "does not exist";
}
But no matter what I use, I’m not able to get this to work.
I’ve also tried using:
if (mailingList[stringLength - 1] == "\r\n")
And this doesn’t work either.
From my output testing, I keep getting “does not exist”.
How do I identify whether the last element is a new line or not?
Any help would be great!
Thanks,
Ray
Well, then the last element probably isn’t a new line.
How to you get the lines?
Do you split a textbox? Then you won’t get new lines, you will get an empty string.
Then you should do something like:
What you likely should do before you take out the lines is to Trim the textbox text.