Share via


carriage return values for C#.net

Question

Thursday, December 18, 2008 8:44 AM

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

All replies (5)

Thursday, December 18, 2008 8:46 AM ✅Answered | 2 votes

string carriagereturn = "\r\n";Please remember to mark the replies as answers if they answered your question :)


Thursday, December 18, 2008 8:47 AM ✅Answered

Thank You Friend, and for Esc?Santhosh


Thursday, December 18, 2008 10:13 AM ✅Answered | 2 votes

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]


Thursday, December 18, 2008 10:31 AM ✅Answered | 7 votes

'\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'.


Thursday, December 18, 2008 11:32 AM

Thank You FriendsSanthosh