Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

new string of string in code

Tags:

c#

in C++ it's

string x = "hello \
Hello";

it's \

in C# I really don't know :) but \ doesn't works and I can't find information. That's annoying.

like image 543
cnd Avatar asked Jan 24 '26 04:01

cnd


2 Answers

Prefix your string with the @ symbol so that the newline character is included in the string.

string x = @"hello 
Hello";
like image 107
Chris Moutray Avatar answered Jan 25 '26 18:01

Chris Moutray


string x = @"Hello
world";
like image 32
naivists Avatar answered Jan 25 '26 18:01

naivists



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!