C# coding standards for private member variables

c++coding-style

I saw two common approaches for coding standards for private member variables:

class Foo
{
    private int _i;
    private string _id;     
}

and

class Foo
{
    private int m_i;
    private string m_id; 
}

I believe the latter is coming from C++. Also, many people specify type before the member variable (e.g. double m_dVal) to indicate that it is a non-constant member variable of the type double?

What are the conventions in C#?

Best Solution

Besides the two you mention, it is very common in C# to not have a prefix for private members.

class Foo
{
    private int i;
    private string id; 
}

That is what I use, and also what is recommended in Microsoft's internal naming guidelines.

See also these .NET naming guidelines.