开发者

How do I add the exceeding string in my code?

collection.Add(new User { Name = "Dede", Description = "Standard Chartered Building

开发者_Python百科

6788 Ayala Avenue, Makati City

886-7143

M - F - 6:30am - 1:00am

S - Sun - closed" });

It errors at the end of the Building, how do I add the succeeding strings in order for it not to have an error? I dont want to lose the format of the spaces and everything that's why.


Try this:

collection.Add(new User { 
    Name = "Dede", 
    Description = 
@"Standard Chartered Building
6788 Ayala Avenue, Makati City
886-7143
M - F       - 6:30am - 1:00am
S - Sun   - closed" 
    });

Notice the @.


Use a verbatim strin literal:

string s = @"this
is all one
string";

The leading @ tells the compiler to use a verbatim literal. The only escape character is for " which must be doubled to "". So:

string s = "single: "" ; double """" ";
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜