C#C
C#4y ago
Hugh

Difference between using { get; set; } and not

I'm pretty new to C# (experienced in C++ and Python), and I was wondering if someone could clarify the following for me:

What is the difference between these two lines:

public string MyValue;
public string MyValue { get; set; }

I understand when you might want to define a getter and setter, but I've seen the second line above a lot, and I don't understand the difference.
Was this page helpful?