© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
C#C
C#•4y ago•
8 replies
lukkasz323

❔ Are these properties the same? `{ get => x; }` vs `{ get; } = x;`

I would like to know if these have any other differences besides the syntax.

Case 1:
public int TileSize { get; } = 64;
public int TileSize { get; } = 64;

Case 2:
public int TileSize { get => 64; }
public int TileSize { get => 64; }


In my code below I have other properties that use the 2nd case, but that's because of more specific reasons, for example:

public (int x, int y) Center 

    {

        get => (_terrain.GetLength(1) / 2, _terrain.GetLength(0) / 2);

    }
public (int x, int y) Center 

    {

        get => (_terrain.GetLength(1) / 2, _terrain.GetLength(0) / 2);

    }

I'm not sure which one would be better in the long run (if there are no other differences).

Previously I always used the 1st case, but here 2nd case seems more consistent with properties below, so this leaves a little confused as I never even thought about the 2nd case.
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
Properties of IConfigurationSection.Get are null?
C#CC# / help
3y ago
Properties vs Fields in C#
C#CC# / help
13mo ago
Are internal properties deserializable?
C#CC# / help
4mo ago