© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
C#C
C#•4y ago•
12 replies
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;

public string MyValue { get; set; }
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.
C# banner
C#Join
We are a programming server aimed at coders discussing everything related to C# (CSharp) and .NET.
61,871Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

❔ Difference between using readonly or { get; }?
C#CC# / help
3y ago
Difference between variable using and statement using?
C#CC# / help
4y ago
Difference between string and string?
C#CC# / help
8mo ago