{"action":"created","issue":{"url":"https://api.github.com/repos/dennisdoomen/csharpguidelines/issues/2","labels_url":"https://api.github.com/repos/dennisdoomen/csharpguidelines/issues/2/labels{/name}","comments_url":"https://api.github.com/repos/dennisdoomen/csharpguidelines/issues/2/comments","events_url":"https://api.github.com/repos/dennisdoomen/csharpguidelines/issues/2/events","html_url":"https://github.com/dennisdoomen/csharpguidelines/issues/2","id":40367966,"number":2,"title":"\"this\" Keyword","user":{"login":"dennisdoomen","id":572734,"avatar_url":"https://avatars.githubusercontent.com/u/572734?v=3","gravatar_id":"","url":"https://api.github.com/users/dennisdoomen","html_url":"https://github.com/dennisdoomen","followers_url":"https://api.github.com/users/dennisdoomen/followers","following_url":"https://api.github.com/users/dennisdoomen/following{/other_user}","gists_url":"https://api.github.com/users/dennisdoomen/gists{/gist_id}","starred_url":"https://api.github.com/users/dennisdoomen/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dennisdoomen/subscriptions","organizations_url":"https://api.github.com/users/dennisdoomen/orgs","repos_url":"https://api.github.com/users/dennisdoomen/repos","events_url":"https://api.github.com/users/dennisdoomen/events{/privacy}","received_events_url":"https://api.github.com/users/dennisdoomen/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2014-08-15T17:39:39Z","updated_at":"2015-06-26T06:54:27Z","closed_at":null,"body":"*Reported by [@ggondim](https://www.codeplex.com/site/users/view/ggondim) via [CodePlex](https://csharpguidelines.codeplex.com/workitem/11345):*\r\n\r\nIn most project cases, the use of \"this\" keyword inside a class is unregulated and some developers use it in a way an some others use in another way. \r\n\r\nIt is really important to regulate the use of the keyword. It is useful in some cases to identify a class member inside a method with many variables, but it is also useless inside a constructor, factory method or even a overloaded method. \r\n\r\nI particullary think the use of \"this\" keyword is only needed on constructor calling and indexable class properties, like below:\r\n\r\n```\r\npublic class MyClass\r\n{\r\n    public MyClass() : this(false)\r\n    { }\r\n\r\n    public MyClass(bool enableConfiguration)\r\n    {\r\n    }\r\n}\r\n````\r\n\r\nand:\r\n```\r\npublic MyClass\r\n{\r\n    this[int index]\r\n    {\r\n        get { return list.ElementAt(index); }\r\n    }\r\n}  \r\n```   \r\nIt is also a \"standard\" proposed in IDesign C# Coding Standard."},"comment":{"url":"https://api.github.com/repos/dennisdoomen/csharpguidelines/issues/comments/115550286","html_url":"https://github.com/dennisdoomen/csharpguidelines/issues/2#issuecomment-115550286","issue_url":"https://api.github.com/repos/dennisdoomen/csharpguidelines/issues/2","id":115550286,"user":{"login":"dg9ngf","id":868315,"avatar_url":"https://avatars.githubusercontent.com/u/868315?v=3","gravatar_id":"","url":"https://api.github.com/users/dg9ngf","html_url":"https://github.com/dg9ngf","followers_url":"https://api.github.com/users/dg9ngf/followers","following_url":"https://api.github.com/users/dg9ngf/following{/other_user}","gists_url":"https://api.github.com/users/dg9ngf/gists{/gist_id}","starred_url":"https://api.github.com/users/dg9ngf/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dg9ngf/subscriptions","organizations_url":"https://api.github.com/users/dg9ngf/orgs","repos_url":"https://api.github.com/users/dg9ngf/repos","events_url":"https://api.github.com/users/dg9ngf/events{/privacy}","received_events_url":"https://api.github.com/users/dg9ngf/received_events","type":"User","site_admin":false},"created_at":"2015-06-26T06:54:27Z","updated_at":"2015-06-26T06:54:27Z","body":"I'd vote for not using `this.` and `base.` prefixes unless it's required. In a class hierarchy, it's not necessary to know on which level something is to use it. Refactoring derived classes is harder if that level is fixed in the code. (Interesting read: http://blog.codinghorror.com/the-best-code-is-no-code-at-all/)\r\n\r\nWhere these keywords are not used as prefix (i. e. `this` alone as a reference or both when calling another or a base constructor), it should be clear that it's not an option to leave them out."}}