这真的是一个简化? [英] Is this really a simplification?

查看:431
本文介绍了这真的是一个简化?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

So I have a pretty simple class with an Id field, and the Id can be set in the constructor.

通常情况下,我将使用这个来清楚地确定类的属性,而不是方法参数。对我来说,这似乎更加清晰。

Typically I will use this to clearly identify the class property as opposed to the method argument. To me this seems clearer.

IDE0003要我删除这个,与消息'名称可以简化',是正确的?

IDE0003 wants me to remove the this, with the message 'Name can be simplified', is that correct?

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

This seems less clear to me, and also allows a casing error to easily result in id = id.

推荐答案

这个关键词几乎总是是不必要的,看的当你使用"本"关键字?

The this keyword almost always is unnecessary, see When do you use the "this" keyword?.

允许外壳错误很容易导致 ID = ID

allows a casing error to easily result in id = id

这将产生对自己的一个警告:

That will yield another warning on its own:

转让;你的意思是分配别的东西?

Assignment made to same variable; did you mean to assign something else?

这篇关于这真的是一个简化?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆