Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Overriding the newline constant ? 1

Status
Not open for further replies.

DLLHell

Programmer
May 9, 2003
69
US
How do you get to use "\" as real data in C#? The compiler keeps trying to reject this...

char bozo = '\';
string strData = "This" + bozo + "andThat"
Newline in constant
Too many characters in character literal

char[] bozo = '\';
string strData = "This" + bozo + "andThat"
Newline in constant
Too many characters in character literal

 
You double-up the slash character:
Code:
string bozo = "\\";
string strData = "This" + bozo + "andThat"
Chip H.


If you want to get the best response to a question, please check out FAQ222-2244 first
 
or you can put a @ in front of the string

x = @"folder\file.txt"
 
You know, I don't really care for using the "@" sign to form strings. Maybe it's because C# is so much like C and C++ that I instinctively use the double-slash method. Call me 0ld-5k00l, I guess!

But they'll both work.

Chip H.


If you want to get the best response to a question, please check out FAQ222-2244 first
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top