-
Notifications
You must be signed in to change notification settings - Fork 2k
Expand file tree
/
Copy pathStrings.cs
More file actions
42 lines (32 loc) · 911 Bytes
/
Strings.cs
File metadata and controls
42 lines (32 loc) · 911 Bytes
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
using System;
using System.Text;
class Strings
{
void Test()
{
var s = "";
object o = null;
s = s + o;
s += o;
var sb = new StringBuilder();
sb.Append(o);
sb.AppendFormat("{0}", o);
sb.AppendFormat("{0}, {1}, {2}, {3}", o, o, o, o);
sb.AppendFormat("{0}, {1}, {2}, {3}", new object[] { o, o, o, o });
string.Format("{0}", o);
string.Format("{0}, {1}, {2}, {3}", o, o, o, o);
string.Format("{0}, {1}, {2}, {3}", new object[] { o, o, o, o });
Console.Write(true);
Console.WriteLine(0);
MyStringFormat("{1}", o);
s = $"Hello: {o}";
}
string MyStringFormat(string s, params object[] args)
{
return string.Format(s, args);
}
string MyRestrictedStringFormat(string s, params string[] args)
{
return string.Format(s, args);
}
}