Skip to content

Instantly share code, notes, and snippets.

@lgolubyev
Created June 15, 2021 11:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lgolubyev/1eacd1331b5e9fd2ee7893f9536a9ce1 to your computer and use it in GitHub Desktop.
Save lgolubyev/1eacd1331b5e9fd2ee7893f9536a9ce1 to your computer and use it in GitHub Desktop.
class Temperature
{
public float Degrees { get; set; }
public Celsius ToCelsius()
{
return new Celsius(((5.0f / 9.0f) * (this.Degrees - 32)));
}
public Fahrenheit ToFahrenheit()
{
return new Fahrenheit(((9.0f / 5.0f) * this.Degrees + 32));
}
}
Celsius cel = new Celsius(10);
Fahrenheit far = cel.ToFahrenheit();
Celsius cel2 = far.ToCelsius();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment