Rob,
Can you send me a link where this is suggested?
In the Design Guidelines for Class Library Developers
microsoft is very inconsistent with naming conventions
while suggesting proper naming conventions.
For example, at
http://msdn.microsoft.com/library/en-
us/cpgenref/html/cpconpropertyusageguidelines.asp?
frame=true
Microsoft lists the example:
[Visual Basic]
Public Class TextBox
Private m_dataSource As String
Private m_dataField As String
Private m_active As Boolean
Public Property DataSource() As String
Get
Return m_dataSource
End Get
Set (...more)
What is the "m_" prefix? If it's for Module, then module
has a different meaning in .net.
The C# example:
public class TextBox
{
string dataSource;
string dataField;
bool active;
public string DataSource
{
get
{
return dataSource;
}
set (...more)
Now for C# they do not use the prefix.
But what if the constructor accepted the dataSource
variable in the C# example, what would the variable name
for the constructor be? ie. localDataSource or
thisDataSource?
Rob, I like your example of prefixing with the underscore
and will probably go with this, but I just can not find
that recommendation on Microsoft's website in the
guidelines section.
Thank you,
Ted
-----Original Message-----
Hi Ted
Microsoft suggests the following:
Public methods or properties are pascal cased. (mixed
case - first letterupper case)
Private or protected methods are camel cased. (mixed
case - first letterlower case)
Private or protected fields (variables) are camel cased
and prefixed with anunderscore.
Variable names do not use Hungarian notation.
Parameters are camel cased.
Public Class TestClass
Private _stringField1 As String
Protected _stringField2 As String
' public fields are not recommended
' use properties instead
Public StringField3 As String
Public Property StringField1() As String
Get
Return _stringField1
End Get
Set(ByVal Value As String)
_stringField1 = Value
End Set
End Property
Public Sub CoolRoutine1(ByVal param1 As String)
End Sub
Private Sub coolRoutine2()
End Sub
End Class
There's a MSDN Webcast on .NET Best Pratices that
discusses this over a fewslides.
--
Rob Windsor [MVP-VB]
G6 Consulting
Toronto, Canada
"Ted" <an*******@discussions.microsoft.com> wrote in
messagenews:14*****************************@phx.gbl...
I'm trying to come up with naming conventions for my
company as we move to C#. I'm looking through the
Naming Guidelines section on MSDN, but I'm unable to find a
recommendation for class scope variables.
Working with WinForms, I believe it would be helpful to
have some type of prefix. In Visual Basic we used
m_variableName. But I can't find any suggestions on
this.
Any help on this would be great. Thanks,
Ted
.