locked
carriage return values for C#.net RRS feed

  • Question

  •  Hi Friends,
    where can i get all carriage return values for C#.net?

    Santhosh
    Thursday, December 18, 2008 8:44 AM

Answers

  • '\r' is carriage return.
    '\n' is new line.
    Environment.NewLine is the sequence of one or more characters that is used to denote a new line of text for many methods, including Console.Write(). It has the value "\r\n" for Windows platforms, and "\n" for unix.

    It is unfortunate that '\n' is called "new line" and Environment.NewLine is also called "new line", and they are different on some platforms (such as on Windows).

    Note: "\r\n" is NOT carriage return. Carriage return is a single character, and it is '\r'.
    • Marked as answer by Santhosh P Thursday, December 18, 2008 11:31 AM
    Thursday, December 18, 2008 10:31 AM
  • string carriagereturn = "\r\n";
    Please remember to mark the replies as answers if they answered your question :)
    • Marked as answer by Santhosh P Thursday, December 18, 2008 11:31 AM
    Thursday, December 18, 2008 8:46 AM
  • What about if you use Environment.NewLine property, it returns the environment specific new line.

    And for ESC:
    - Set form's KeyPreview property to true
    -  Handle form's KeyDown events

    private void Form1_KeyDown(object sender, KeyEventArgs e) 
            { 
                if (e.KeyData == Keys.Escape) 
                { 
                    Console.WriteLine("ESC pressed."); 
                    e.Handled = true
                } 
                else 
                { 
                    Console.WriteLine("Some other key pressed."); 
                } 
            }      


    Tomi Airaksinen - MCPD [Remember to click "mark as answered" when you get a correct reply to your question]
    • Marked as answer by Santhosh P Thursday, December 18, 2008 11:31 AM
    Thursday, December 18, 2008 10:13 AM
  • Thank You Friend, and for Esc?
    Santhosh
    • Marked as answer by Santhosh P Thursday, December 18, 2008 11:31 AM
    Thursday, December 18, 2008 8:47 AM

All replies

  • string carriagereturn = "\r\n";
    Please remember to mark the replies as answers if they answered your question :)
    • Marked as answer by Santhosh P Thursday, December 18, 2008 11:31 AM
    Thursday, December 18, 2008 8:46 AM
  • Thank You Friend, and for Esc?
    Santhosh
    • Marked as answer by Santhosh P Thursday, December 18, 2008 11:31 AM
    Thursday, December 18, 2008 8:47 AM
  • What about if you use Environment.NewLine property, it returns the environment specific new line.

    And for ESC:
    - Set form's KeyPreview property to true
    -  Handle form's KeyDown events

    private void Form1_KeyDown(object sender, KeyEventArgs e) 
            { 
                if (e.KeyData == Keys.Escape) 
                { 
                    Console.WriteLine("ESC pressed."); 
                    e.Handled = true
                } 
                else 
                { 
                    Console.WriteLine("Some other key pressed."); 
                } 
            }      


    Tomi Airaksinen - MCPD [Remember to click "mark as answered" when you get a correct reply to your question]
    • Marked as answer by Santhosh P Thursday, December 18, 2008 11:31 AM
    Thursday, December 18, 2008 10:13 AM
  • '\r' is carriage return.
    '\n' is new line.
    Environment.NewLine is the sequence of one or more characters that is used to denote a new line of text for many methods, including Console.Write(). It has the value "\r\n" for Windows platforms, and "\n" for unix.

    It is unfortunate that '\n' is called "new line" and Environment.NewLine is also called "new line", and they are different on some platforms (such as on Windows).

    Note: "\r\n" is NOT carriage return. Carriage return is a single character, and it is '\r'.
    • Marked as answer by Santhosh P Thursday, December 18, 2008 11:31 AM
    Thursday, December 18, 2008 10:31 AM
  • Thank You Friends
    Santhosh
    • Proposed as answer by mkoumoudjian Tuesday, May 24, 2011 1:51 PM
    • Unproposed as answer by mkoumoudjian Tuesday, May 24, 2011 1:51 PM
    Thursday, December 18, 2008 11:32 AM