After you’ve been programming for a long time with a language, you pick up certain coding standards or styles. With Delphi it’s things like prefixing private variables with f and putting private declarations before protected, which in turn are before public ones etc etc. Most of this comes from the VCL.
Is there any recognized coding standard or style in the C# world? I’m tempted to put an f in front of my private member variables but this would only make sense to other Delphi developers.
Check out the following. It’s Microsoft’s take on the question.
http://msdn.microsoft.com/en-us/library/czefa0ke(VS.71).aspx
Just talking about the very basics for c#: Private class fields are prefaced with an underscore. Public class members are capitalized. Method parameters are lower case. For example:
Note that in order to be CLS compliant, you should not depend on casing to differentiate between variables. Also, it’s considered bad practice to preface parameters or other variables with the type OR with some form of hungarian notation (which nobody gets right anyway. Read this).
The only reason private fields are prefaced with an underscore is to differentiate them from method parameters.
One practice I run into a lot is the use of the “this.” notation. Besides being annoying, it’s completely unnecessary when things are named correctly.