相关疑难解决方法(0)

使用隐式类型的局部变量

我刚刚安装了ReSharper的试用版,我注意到的第一件事就是它总是建议用隐式类型的替换显式类型的局部变量,例如:

public string SomeMethod(int aParam)
{
    int aNumber = SomeOtherMethod(aParam);
    // should be changed to:
    var aNumber = SomeOtherMethod(aParam);
}
Run Code Online (Sandbox Code Playgroud)

我认为显式类型变量更具可读性(更明确).

您如何看待ReSharper的建议?使用隐式类型变量有什么优势吗?你什么时候使用implicit/explict vars?

c# coding-style implicit-typing

64
推荐指数
5
解决办法
4万
查看次数

标签 统计

c# ×1

coding-style ×1

implicit-typing ×1