© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
C#C
C#•3y ago•
37 replies
__dil__

❔ ✅ Struct equality

hi!

I have a struct such as this one:
public readonly struct InternerId
{
    private readonly int _id;

    internal InternerId(int id)
    {
        _id = id;
    }
}
public readonly struct InternerId
{
    private readonly int _id;

    internal InternerId(int id)
    {
        _id = id;
    }
}


What's the correct way to implement equality between two
InternerId
InternerId
s based on
_id
_id
? I don't want equality with any other type except itself.
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

✅ Equality confusion
C#CC# / help
4mo ago
difference between `struct` and `ref struct`
C#CC# / help
12mo ago
✅ Two methods: struct and non-struct
C#CC# / help
2y ago