The Evolution of .NET Technical Documentation and Naming Conventions
TLDR
- The MSDN platform has officially been retired, and all relevant technical documentation has been migrated to Microsoft Learn.
- When searching for legacy .NET documentation, it is recommended to visit the ".NET Legacy Documentation" section on Microsoft Learn.
- The naming convention for C# private fields has shifted from "no prefix" to "using an underscore (_) prefix."
- Modern .NET conventions recommend using
_camelCasefor private instance fields,s_camelCasefor static fields, andt_camelCasefor thread-static fields.
The Transformation of the MSDN Platform and Documentation Access
When you might encounter this issue: When developers attempt to search for legacy .NET technical documentation or refer to MSDN links.
In the past, .NET technical documentation was primarily centralized on the MSDN platform. This platform has now been officially retired, and the content has been migrated to Microsoft Learn. If you need to access legacy .NET documentation, please refer to the following resources:
- MSDN Code Gallery Retirement Notice
- Update on the migration of MSDN and TechNet to docs.microsoft.com
- .NET Legacy Documentation Portal
TIP
Due to differences in documentation update strategies, older data from before .NET Framework 4 may be incomplete.
The Evolution of C# Field Naming Conventions
When you might encounter this issue: When development teams are establishing coding styles or maintaining cross-generational .NET projects and encounter ambiguity regarding whether private fields should have prefixes.
Historical Differences in Conventions
Early .NET Framework coding conventions tended to avoid any prefixes and recommended using this. to distinguish between member variables and local variables. However, with the development of .NET Core, the official guidelines began promoting a new naming convention in 2016 to improve code maintainability and consistency.
Modern .NET Naming Conventions
According to current official recommendations, the naming of private fields should follow these rules:
- Private instance fields: Use an
_prefix followed bycamelCase(e.g.,_myField). - Static fields: Use an
s_prefix. - Thread-static fields: Use a
t_prefix.
Conclusion and Recommendations
Since .NET 5, the official guidelines have unified the aforementioned style. If developers examine the early Reference Source, they will find a mix of no prefix, _ prefix, and m_ prefix usage; this is a result of historical evolution. It is recommended that modern projects consistently follow the C# Identifier Naming Rules and Conventions on Microsoft Learn to ensure consistency in code style.
Change Log
- 2024-09-20 Initial document creation.
