C#C
C#4y ago
Xellez

Dictionary Implementation, but with custom class as key

I have implemented a dictionary like this code file
Now 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;
    }
}
can I pass my class as my key or do I need to adjust my dictclass ?
Dict.cs3.17KB
Was this page helpful?