steve steve - 1 year ago 108
C# Question

What is the { get; set; } syntax in C#?

I am learning ASP.NET MVC, and I can read English documents, but I don't really understand what is happening with this code:

public class Genre
public string Name { get; set; }

What does this mean:
({ get; set; })

Answer Source

It's a so-called auto property, and is essentially a shorthand for the following (similar code will be generated by the compiler):

private string name;
public string Name
    { = value;
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download