© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
C#C
C#•4y ago•
13 replies
Xellez

Dictionary Implementation, but with custom class as key

I have implemented a dictionary like this code file
Now
Dictionary.Add(10, "Washington");
Dictionary.Add(10, "Washington");
will work, but what if I want the key to be the latitude and longitude of the city?

public class GeoLocation 
{
  private float _latitude, _longitude;

  public GeoLocation(float latitude, float longitude) {
        _latitude = latitude;
        _longitude= longitude;
    }
}
public class GeoLocation 
{
  private float _latitude, _longitude;

  public GeoLocation(float latitude, float longitude) {
        _latitude = latitude;
        _longitude= longitude;
    }
}
can I pass my class as my key or do I need to adjust my
dict
dict
class ?
Dict.cs3.17KB
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

Derived class , BaseClass, Dictionary
C#CC# / help
2y ago
❔ dictionary as datasource
C#CC# / help
3y ago
need help with a stack class implementation
C#CC# / help
3y ago
Finding Index of Dictionary Key
C#CC# / help
2y ago