C
Chad Myers
VM said:What's the correct variable naming in C#? How should a form be called (eg.
Frm_myForm)? or an int variable (eg. Int_Var) or a DataGrig (eg. DG_myGrid)?
I'm writing an application but I would like to name variables, objects,
etc... corectly so everyone knows what the variable is and what it holds
when they look at it and make the code easier to read.
Thanks.
Please follow this MSDN guide to naming conventions:
http://tinyurl.com/2cun [MSDN]
Note that this applies to externally visible members
like Method names, Properties, etc.
Internally, you can use whatever you want, but remember
that maintainability is a big part of software
development and I strongly urge you, and I know
this will spawn flaming, not to use Hungarian Notation
since there are maintainability issues with it.
It's best not to specify the type of object in the
variable name. For Windows controls, there's some
grey area. txtUserName or userNameTextBox are
usually good, but for every string doing things like
strUserName or pobjsysstrUserName or anything
crazy like that.
Also, every reference in .NET is essentially
a pointer to an Object-based class, so labelling
it pobj is pointless and redundant. Please think
of us maintenance programmers before you do
something like that
![Smile :) :)](/styles/default/custom/smilies/smile.gif)
where they labelled everything with obj******
and it drove me nuts)
-c