Per*_*ack 5 c# implicit-typing
在C# Coding Conventions 中,当变量的类型从赋值的右侧很明显时,为什么 Microsoft 建议使用隐式类型?
我知道没有必要声明它,因为它很明显,但为什么要提出建议?显式键入不是使代码更易于遵循吗?
var str1 = "This is clearly a string.";
Run Code Online (Sandbox Code Playgroud)
对比
string str2 = "This is clearly a string.";
Run Code Online (Sandbox Code Playgroud)
这有编译时间的好处吗?