Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Naming convention for a C# Dictionary

How do we name a dictionary variable?

Say in my method I have Dictionary<string, List<string>> dictionary;, where the keys of the dictionary are country names and the values are lists of province/state names. How should I rename dictionary?

I know we can create a Country class for this example. But please don't mention this alternative because I'm thinking of good naming convention here.

like image 888
Shuo Avatar asked Dec 02 '10 00:12

Shuo


People also ask

Does C use camelCase or Snakecase?

Classic C doesn't use camel-case; I've written code in camel-case in C, and it looks weird (so I don't do it like that any more). That said, it isn't wrong - and consistency is more important than which convention is used.

Should I use camelCase C?

The general practice for a C style language like Java or JS is to use camelCase for all variables and object members (properties & methods), and PascalCase for class names and constructors. Namespaces (or Packages in Java world) are usually in camelCase. But some languages make an exception to that.

Should function names be capitalized in C?

All methods and functions should begin with a capital letter. The first letter of each word should also be capitalized. Special characters such as dashes and underscores are prohibited.

What are naming conventions examples?

Good naming examples include: [Project number] - Data Use Agreement - [Title of research project] Approval - Change to employee travel policy - February 2014.


2 Answers

ProvincesByCountry 
like image 191
Heinzi Avatar answered Sep 21 '22 12:09

Heinzi


I use mostly one of these:

  • CountryToStatesDictionary
  • CountryToStatesMap
  • CountryToStatesMapping
like image 25
herzmeister Avatar answered Sep 19 '22 12:09

herzmeister