3 ms·
>, but the closest I will get to accepting it is in a constructor where you are passing values that will be stored as private fields. int maxAmount; SomeCl
by jasode 6y ago
>, but the closest I will get to accepting it is in a constructor where you are passing values that will be stored as private fields. int maxAmount; SomeClass(int maxAmount) => this.maxAmount = maxAmount;
>But even in this case, you should really be using Pascal casing as per Microsoft's Capitalization Conventions.
Like other sibling comments stated, I also disagree. The C# compiler knows about "this" but not about arbitrary Pascal naming conventions. Therefore, it's more reliable to choose the syntax where keyboard typos can be detected by the compiler.
The blog author's advice would make more sense if C# compiler assigned semantic meaning to alpha case like Golang. In Golang, the first letter of identifiers being upper vs lowercase changes the scope of visibility: https://golang.org/doc/effective_go.html#names https://golang.org/doc/effective_go.html#names
Also an excerpt from Microsoft guidelines cited in sibling comment that recommends using "this." :
>Do not use a prefix for member variables (_, m_, s_, etc.). If you want to distinguish between local and member variables you should use “this.” in C# and “Me.” in VB.NET.