èString Literal is a set of characters enclosed by double
quotes.
“this is
string literal”
class Program
{
static void Main(string[]
args)
{
string
s = @"this is string1
literal";
Console.WriteLine(s);
Console.ReadLine();
}
}
è class
Program
{
static void Main(string[]
args)
{
string
s = "this is string1 \nliteral";
Console.WriteLine(s);
Console.ReadLine();
}
}
èVerbatim string literal starts with @ , which is followed by
a quoted string. The contents of the quoted string are accepted without modification
and can span two or more lines. So we can avoid escape sequence.
class Program
{
static void Main(string[] args)
{
string s = @"this is ""string1"" literal";
Console.WriteLine(s);
Console.ReadLine();
}
}
class Program
{
static void Main(string[]
args)
{
string
s = "this is \"string1\"
literal";
Console.WriteLine(s);
Console.ReadLine();
}
}
ð Verbatim string literals are wonderful
benefit for many formatting situation.
No comments:
Post a Comment