-
Notifications
You must be signed in to change notification settings - Fork 2k
Expand file tree
/
Copy pathStrings.cs
More file actions
59 lines (50 loc) · 1.33 KB
/
Strings.cs
File metadata and controls
59 lines (50 loc) · 1.33 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
using System;
public class MyTestClass
{
public string M1(int x)
{
// Use an expression that spans across multiple lines in a string interpolation.
return $"This is my int {x switch
{
42 => "forty two",
_ => "something else"
}}.";
}
public void M2()
{
// Raw string literal.
var message1 = """
This is my very long
text message that spans
accross multiple lines
and is very useful.
""";
// String interpolation using a raw string literal.
var message2 = $"""
The nested message
is "{message1}" and everything
spans multiple lines.
""";
// String interpolation using a raw string literal that requires double curly braces.
var message3 = $$"""
Show no curly braces: {{message1}}
Show matching set of curly braces: {{{message2}}}
""";
}
public void M3()
{
// UTF-8 encoded.
var x = "AUTH8: "u8;
// UTF-16 encoded.
var y = "AUTH16: ";
// UTF-8 encoded vertabim.
var z = @"AUTH8:
<username> "u8;
// UTF-8 encoded raw literal.
var w = """
The nested message
is UTF-8 encoded and
spans multiple lines.
"""u8;
}
}