Reputation: 14964
What are the most common naming conventions in C# for classes, namespaces and methods? Is it common to have getter/setter style methods as in Java?
Upvotes: 2
Views: 3045
Reputation: 158379
Guidelines for Names (from Design Guidelines for Developing Class Libraries, in which you will also find sections about properties and choosing between properties and methods. In that last article, you will find the following:
Do use a property, rather than a method, if the value of the property is stored in the process memory and the property would just provide access to the value.
Upvotes: 11
Reputation: 150198
There are a few common patterns out there. One I frequently see and use in my own projects is:
namespace Company.Concept.SubConcept
{
public class MyClass
{
private MyType someData;
public MyType SomeData
{
get { return someData; }
set { someData = value; }
}
public void MyMethod()
{
}
}
}
Upvotes: 2
Reputation: 564831
MSDN provides Design Guidelines that spell this out in detail.
Upvotes: 0
Reputation: 31928
I think that most projects are using the IDesign CSharp Coding Standard
Upvotes: 2
Reputation: 15609
Check out Lance's page
http://weblogs.asp.net/lhunt/pages/CSharp-Coding-Standards-document.aspx
and
Upvotes: 0
Reputation: 755397
No it is not common to use getter /setter style names in C#. Properties should be used for almost all places you would use a getter / setter in Java.
IMHO, the defacto standard for naming conventions comes from the Framework Design Guidelines. It's enforced by several tools (FxCop) and is the dominant style of many libraries including the BCL.
Upvotes: 5