dimanche 26 avril 2015

Preferred method for declaring properties in C# [duplicate]

This question already has an answer here:

I have seen property declarations in C# that follow both of the following patterns.

class MyClass
{
    public string MyString { get; set; }
}

class MyOtherClass
{
    public string MyString;
}

Is there a reason for using the first style over the second? Are there any differences between the two?

Aucun commentaire:

Enregistrer un commentaire