© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
C#C
C#•13mo ago•
15 replies
Faker

Properties vs Fields in C#

Hello guys, can someone explain what is the difference between Properties and Fields in C# please. At first I thought that properties and fields were the same thing because they are accessed the same way, like writing
person.name
person.name
something like that. But this isn't the case. How do properties work? I noticed they work as method but they don't have any parentheses. They should be named the same way as the fields?
public class Person
{
    private int age;  // Private field

    // Property: Combines getter and setter
    public int Age
    {
        get { return age; }              // Getter
        set
        {
            if (value >= 0)              // Validation
                age = value;             // Setter
        }
    }
}
public class Person
{
    private int age;  // Private field

    // Property: Combines getter and setter
    public int Age
    {
        get { return age; }              // Getter
        set
        {
            if (value >= 0)              // Validation
                age = value;             // Setter
        }
    }
}
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

Properties vs constructor:
C#CC# / help
14mo ago
OOP - Properties and Fields
C#CC# / help
13mo ago
❔ dotnet vs C#
C#CC# / help
3y ago
Reflection and customclass in list properties c#
C#CC# / help
2y ago