Naming Private Fields (Addendum)
January 30th, 2007 by EricThis is just a quick addition to the previous posting, confirming the alleged use of m_ by Microsoft in their own code.
Lutz Roeder’s .NET Reflector is a fascinating tool for various reasons, including its ability to show all the .NET Framework classes that use prefixes on member variables. There are a bunch. Here is a very small sample of venerable classes that use m_:
- System.Int32
- System.String
- System.Threading.Thread
- System.Reflection.Assembly
- System.Environment
- System.Globalization.CultureInfo
- System.Net.Connection
- System.Net.HttpWebRequest
- System.Net.IPAddress
- System.Uri
- System.WeakReference
And here are a few of the classes that use a leading underscore for field names, though there aren’t as many in this category:
- System.AppDomain
- System.Guid
- System.Console
- System.Exception
- System.Collections.ArrayList
- System.Delegate
- System.TimeSpan
Eric Gunnerson raises the issue yet again. http://blogs.msdn.com/ericgu/archive/2007/06/15/to-m-or-no-to-m-that-is-the-question.aspx