Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6087515
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T11:52:44+00:00 2026-05-23T11:52:44+00:00

The logic I’m trying to use is this: 1. Look at the last element

  • 0

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

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T11:52:45+00:00Added an answer on May 23, 2026 at 11:52 am

    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:

    if (string.IsNullOrWhiteSpace(mailingList.LastOrDefault())
    

    What you likely should do before you take out the lines is to Trim the textbox text.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

We currently use this logic to center every new window: ASSIGN {&WINDOW-NAME}:X = (SESSION:WIDTH-PIXELS
My logic is if( !this.draginited() ) // a drag-disabled element shouldn't get pass here,
I'm having a logic problem trying to return a collection of objects from a
I very frequently use logic something like this when writing to normalised databases. In
I got this logic in a control to create a correct url for an
SQLite3::SQLException: SQL logic error or missing database error when do insert, update and delete
This logic is written in a function with signature private void showDialog(final AdapterView<? extends
I have some controller logic: public function seafood() { $this->set('title', 'Seafood restaurants in and
If the logic within this method is run from an event handler such as
This is a general logic question, common to most introductory language and machines courses.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.