Skip to content

Evolution of .NET Technical Documentation and Naming Conventions

TLDR

  • .NET technical documentation has been fully migrated from MSDN to the Microsoft Learn platform.
  • Legacy .NET documentation can be found in the "Previous Versions" section of Microsoft Learn.
  • The naming convention for C# private fields has evolved from "no prefix" to "using an underscore _ prefix."
  • Modern .NET conventions (derived from .NET CoreFX) recommend: _ for private fields, s_ for static fields, and t_ for thread-static fields.

Transformation and Migration of the MSDN Platform

When you might encounter this issue: When developers attempt to search for legacy .NET technical documentation or API references, they may find that original MSDN links are broken or redirected.

In the past, .NET technical documentation was primarily centralized on the MSDN (Microsoft Developer Network) platform. This platform has now been officially retired, and all content has been migrated to Microsoft Learn. To find legacy .NET documentation, you can search via Microsoft Learn Previous Versions.

Conclusion: MSDN is now history; current .NET technical documentation is unified under Microsoft Learn.

Evolution of C# Private Field Naming Conventions

When you might encounter this issue: When maintaining projects that span different eras (.NET Framework vs. .NET Core/5+), you may notice significant differences in coding styles, leading to inconsistent naming conventions.

Early Convention: No Prefix

In the early .NET Framework era, the official recommendation was to use no prefix for member variables. If it was necessary to distinguish between local variables and member variables, the use of the this. keyword was recommended.

Modern Convention: Using an Underscore Prefix

With the development of .NET Core, the .NET CoreFX Coding Style proposed by the official team in 2016 established new naming conventions, which became the mainstream standard after .NET 5.

Modern conventions recommend the following:

  • Private instance fields: Start with _, followed by camelCase.
  • Static fields: Start with s_.
  • Thread-static fields: Start with t_.
  • Static readonly fields: static should be placed before readonly (e.g., static readonly).

Verification Results

Observing the Reference Source, one can find that early codebases contained a mix of no prefix, _ prefix, and m_ prefix. Modern .NET source code and open-source projects now generally follow the _ prefix convention. This not only improves code readability but also makes the distinction between member variables and local variables more intuitive.

Conclusion: Modern .NET development should prioritize the _ prefix naming convention to align with official documentation and mainstream open-source project styles.

Change Log

  • 2024-09-20 Initial document created.