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

  • Home
  • SEARCH
  • 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 1020469
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T11:10:12+00:00 2026-05-16T11:10:12+00:00

Current best practice is to use Environment.NewLine in your code to, well, start a

  • 0

Current best practice is to use Environment.NewLine in your code to, well, start a new line. I would like to be able to use an alias or overloaded operator in my code so that it is more concise.
Instead of this:

MessageBox.Show("My first line here" + Environment.NewLine + "My second line here");

I would like to have something like this:

MessageBox.Show("My first line here" + NL + "My second line here");

How can I easily set this up one time as an IDE setting, or for a whole project/namespace?

An alias or overloaded operator is that comes to mind, but not sure if there is a good way of doing a global alias that is more concise than Environment.NewLine, and I’ve never done an overloaded operator before, so not familiar with the ins and outs of that.

  • 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-16T11:10:12+00:00Added an answer on May 16, 2026 at 11:10 am

    Simple shortening method. Pop this class in one of your utility assemblies:

    namespace MyCompany
    {
        public static class E
        {
            public static readonly string NL = System.Environment.NewLine;
        }
    }
    

    then you can happily use it as such:

    using MyCompany;
    
    MessageBox.Show("My first line here" + E.NL + "My second line here");
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm learning Grails/GORM and as I've understood it the current best practice is not
What are the current best practices in the Rails world for displaying a calendar
What is the best way to generate a current datestamp in Java? YYYY-MM-DD:hh-mm-ss
(MFC Question) What's the best way to determine the current displayed client area in
What is the best way to get the current system time milliseconds?
What is the best method to determine if the current time is AM or
Whats the best way to round in VBA Access? My current method utilizes the
I am trying to work out the best database model for the current setup:
I need custom behavior for tab keys in RichTextEdit control. Currenty the best I
Current, I've got a stored procedure that has a main goal of doing a

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.