示例(注意案例):
string s = "Hello world!";
String s = "Hello world!";
Run Code Online (Sandbox Code Playgroud)
每种使用的准则是什么?有什么区别?
我正在使用反射来打印方法签名,例如
foreach (var pi in mi.GetParameters()) {
Console.WriteLine(pi.Name + ": " + pi.ParameterType.ToString());
}
Run Code Online (Sandbox Code Playgroud)
这很好用,但它打印出基元类型为"System.String"而不是"string"和"System.Nullable`1 [System.Int32]"而不是"int?".有没有办法在代码中查找参数的名称,例如
public Example(string p1, int? p2)
Run Code Online (Sandbox Code Playgroud)
版画
p1: string
p2: int?
Run Code Online (Sandbox Code Playgroud)
代替
p1: System.String
p2: System.Nullable`1[System.Int32]
Run Code Online (Sandbox Code Playgroud)