c# - Creating a weatherapp, following a githubproject, how can I get the tempetaure in celsius instead of fahrenheit? -
https://github.com/jamesmontemagno/myweather.forms
this project using , works perfectly. explain in title trying degrees in celsius instead of fahrenheit have not yet figured out.
maybe not possible when examine code see line looks this:
var unit = isimperial ? "f" : "c"; temp = $"temp: {weatherroot?.mainweather?.temperature ?? 0}°{unit}"; condition = $"{weatherroot.name}: {weatherroot?.weather?[0]?.description ?? string.empty}";
does var unit = isimperial ? "f" : "c";
mean f in fahrenheit , c in celsius?
to answer answer question:
does var unit = isimperial ? "f" : "c"; mean f in fahrenheit , c in celsius?
it in ternary operator format. equivalent of
string unit = string.empty; if(isimperial == true){ unit = "f" }else{ unit = "c" }
it storing string later use "50 f" or "50 c", f , c equal variable unit;
if need have app use metric units, celcius, somewhere in app (maybe on app load?) set helpers.settings.isimperial = false. not have manually convert temperatures because call rest api you. app set handle sicne displaying temperature, in either celcius fahrenheit you.
edit: did
public app() { helpers.settings.isimperial = false; ..... }
Comments
Post a Comment