c# - 这真的是一种简化吗?

标签 c# visual-studio-2015

所以我有一个非常简单的类,它有一个 Id 字段,Id 可以在构造函数中设置。

通常我会使用 this 来清楚地识别类属性而不是方法参数。对我来说,这似乎更清楚。

IDE0003 要我删除 this,消息是“Name can be simplified”,对吗?

这对我来说似乎不太清楚,并且还允许外壳错误很容易导致 id = id

enter image description here

最佳答案

这个其他问题的答案是您可以配置编辑器来移除该行为。我个人喜欢“这个”

Tools > Options > Text Editor > C# > Code Style and check Qualify member access with 'this'

Visual Studio 2015 - Change Light Bulb, Quick Action settings

关于c# - 这真的是一种简化吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33186954/

相关文章:

c# - 从列表中删除随机项目 C#

c# - 如何将/features :strict (of csc. exe 的等价物指定给 msbuild.exe 或 .csproj 文件?

git - 在 Visual Studio 中执行 GIT PULL 时如何正确处理 merge

Git 2.6.3 和 Visual Studio 2013/2015 集成

c# - 错误处理中间件捕获永远不会被捕获

c# - 如何从 Windows 8 应用程序启动进程?

c# - 在对其中一列求和时合并 N 个数据表

git - **Visual Studio 2015,我应该将 Project.sln.ide\* 文件提交到 git 中吗?

visual-studio-2012 - VS 2012 构建 Hello World : "The operation could not be completed. The parameter is incorrect" 时出错

c# - 从经典 ASP 调用 .Net C# DLL 方法