Microsoft VB.NET naming convention

2020-05-23 09:23发布

问题:

Is there any standard naming convention for VB.NET ?

Based your programming experiences, would like to share your naming convention for VB.NET ?

Are there any guides for this kind of good practice besides patterns & practices Guidance Explorer and Guidance Share ?

Thanks. Happy Weekend.

回答1:

As Mehrdad said, VB.NET follows the General .NET naming conventions. More specificly:

  • Types, events, read-only static fields, methods, namespaces, properties: PascalCase
  • Parameters: camelCase
  • Acronyms of two characters: DB, with the exception of Id and Ok
  • Acronyms of three or more characters: Html or html, depending on context, but never HTML
  • Compound words: Hashtable, not HashTable, except for some common terms like FileName
  • Do not use separators like hyphens (-) or underscores (_) between words
  • Do not use Hungarian notation


回答2:

I use this guide on "net Naming Conventions and Programming Standards - Best Practices": http://10rem.net/articles/net-naming-conventions-and-programming-standards---best-practices



回答3:

VB.NET shares the naming convention of the .NET Framework. PascalCase for types and public stuff, camelCase otherwise.



回答4:

Enable Visual Studio "Code Analysis" to check your code against several Microsoft-sanctioned naming conventions.



回答5:

Take a peek at this question. It is essentially the same question regarding C#, however most of of the links and answers provided apply to both languages.