Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What are the C# "formatting" standards?

In C#(.NET), what are the regular "formatting" standards?

For instance, for parameter names, so far I noticed camelCase with no prefix, is that right? For object names, camelCase and no prefix either, right?

For namespaces, classes, functions and properties, first letter of the word is capitalized and there is no prefix, is this right (again)?

How are "temporary" objects formatted?

Example:

namespace TestNamespace
{
    class MyOwnCoolClass
    {
        MyOwnCoolClass(int length, BinaryWriter writer)
        {
            BinaryWriter tempbw = new BinaryWriter(length);
            return tempbw;
        }
    }
}

(Note: This code is not valid, I know, it's just to demonstrate formatting). Thanks!

like image 565
Lazlo Avatar asked Aug 12 '09 17:08

Lazlo


People also ask

What is meant by C?

" " C is a computer programming language. That means that you can use C to create lists of instructions for a computer to follow. C is one of thousands of programming languages currently in use.

What kind of language is C?

C is a procedural programming language. It was initially developed by Dennis Ritchie in the year 1972. It was mainly developed as a system programming language to write an operating system.

What is C and its uses?

C programming language is a machine-independent programming language that is mainly used to create many types of applications and operating systems such as Windows, and other complicated programs such as the Oracle database, Git, Python interpreter, and games and is considered a programming foundation in the process of ...


2 Answers

If you use StyleCop, you'll get good consistency with the Microsoft .NET Design Guidelines for Developing Class Libraries. StyleCop also enforces several additional things like spacing, ordering of items in a file, and naming of non-public code elements.

like image 50
Sam Harwell Avatar answered Oct 23 '22 17:10

Sam Harwell


Full guidelines from Microsoft can be found in the Class Design Guidelines. It's old, but I haven't yet found anything updated on MSDN, and I believe it is still the standard set reccomendations

like image 31
David Avatar answered Oct 23 '22 16:10

David