Question

Let's say I own a domain called www.john-doe.com. How would I write an appropriate namespace in C#?

Is it Com.John_Doe.<product-name> ?

All I read about C# namespace convetions is that it should use PascalCase. But what about the minus sign? Is it appropriate to write an underscore for it?

Was it helpful?

Solution

According to .NET namespace conventions, you should use pascal casing in namespaces (unless that goes against non-standard casing your company/brand/product uses). And according to capitalization conventions, pascal casing should not include underscores. General naming conventions also tell you to not use hyphen (which will actually produce compiler errors in C# anyway).

Unless Com is intended to be replaced with your company name (from the context, "John Doe" sounds like the company) You should just go with:

JohnDoe.<ProductName>

OTHER TIPS

I think it is personal preference. E.g. my preference is JohnDoe.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top