struct GeoCodeThe error is:
{
public double Longitude { get; set; }
public double Latitude { get; set; }
public GeoCode(double longitude, double latitude)
{
this.Longitude = longitude;
this.Latitude = latitude;
}
}
Backing field for automatically implemented property 'Program.GeoCode.Latitude' must be fully assigned before control is returned to the caller. Consider calling the default constructor from a constructor initializer ...
The 'this' object cannot be used before all of its fields are assigned to ...It's okay with:
struct GeoCodeSounds like the issue of automatic properties on structs in .NET 2.0. To fix it, just follow the error description "Consider calling the default constructor from a constructor..":
{
public double Longitude;
public double Latitude;
public GeoCode(double longitude, double latitude)
{
this.Longitude = longitude;
this.Latitude = latitude;
}
}
struct GeoCode
{
public double Longitude { get; set; }
public double Latitude { get; set; }
public GeoCode(double longitude, double latitude) : this()
{
this.Longitude = longitude;
this.Latitude = latitude;
}
}