Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
405 views
in Technique[技术] by (71.8m points)

.net - Pascal casing or Camel Casing for C# code?

I've been arguing with my coworkers about Pascal casing (upper camel case) vs. lower CamelCasing. They are used to lower camel casing for everything from table names in SQL databases to property naming in C# code but I like Pascal casing better, lower camel casing for variables and Pascal casing for properties:

string firstName;
public string FirstName {
...
}

But they are used to this:

string _firstname;
public string firstName {
...
}

I try to keep up with their "standard" so the code looks the same but I just don't like it.

I've seen that at least the .NET framework uses this convention and that is how I try to keep my code, e.g.:

System.Console.WriteLine("string")

What do you use/prefer and why? I'm sorry if somebody else asked this question but I searched and did not find anything.

Update: I've given a method example and not a property but it's the same. As I stated in the first paragraph my colleagues use the Pascal convention for everything (variables, methods, table names, etc.)

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

A link to the official design guidelines might help. Specifically, read the section on Capitalization styles.

In the grand scheme of things, Pascal vs Camel doesn't matter that much and you're not likely to convince anyone to go back over an existing code base just to change the case of names. What's really important is that you want to be consistent within a given code base.

I'm just happy as long as you're not using Hungarian.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...