This is my class.
public class Report
{
public string Name { get; set; }
public string City { get; set; }
public string Country { get; set; }
public string Lat { get; set; }
public string Long { get; set; }
public string Type { get; set; }
public DateTime CreateDate { get; set; }
public override bool Equals(object obj)
{
if (obj == null)
return false;
var y = obj as Report;
if (y == null)
return false;
return
this.Name == y.Name &&
this.Long == y.Long &&
this.Lat == y.Lat;
}
public override int GetHashCode()
{
return (this.Name + this.Long + this.Lat).GetHashCode();
}
}
So this is my code and somehow non-unique values snick in when I create a new HashSet? Any ideas? It looks like my post is mostly code so I need to add some more details.
I am creating the objects passed in the HashSet with this method (it is a console app made just for testing purposes, nothing fancy)
static Report CreateReport(dynamic report)
{
var result = new Report();
result.City = report.city.ToString();
result.Name = report.name.ToString();
result.Country = report.country.ToString();
result.Long = report.@long.ToString();
result.Lat = report.lat.ToString();
result.Type = report.type.ToString();
result.CreateDate = DateTime.Now;
return result;
}