© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
C#C
C#•4y ago•
33 replies
LDami

Is there any benefit to write a Property with a private variable ?

Why:
private int myVar;
public int MyVar { get => myVar; set => myVar = value; }
private int myVar;
public int MyVar { get => myVar; set => myVar = value; }

may be better than:
public int MyVar;
public int MyVar;

if we let get and set public ?
C# banner
C#Join
We are a programming server aimed at coders discussing everything related to C# (CSharp) and .NET.
61,871Members
Resources
Recent Announcements

Similar Threads

Was this page helpful?

Similar Threads

any benefit to async?
C#CC# / help
4y ago
Is there any way to *conditionally* set a property with EF `.ExecuteUpdateAsync()`?
C#CC# / help
3y ago
✅ Is there any benefit to separating your service models and repository entities?
C#CC# / help
8mo ago
❔ Is there a way to get a Private field?
C#CC# / help
3y ago