I have created a class for handling Unit Conversion in C#. It is not working as it should only returning strings.
Here is the class:
using System;
us
Sorry, can't be done. Enums are strictly integers/bytes. Really, they are supposed to be their own type.
You can try:
enum Units() {
Grams ,
KiloGrams ,
Milligram
}
public function GetUnitsFloatValue(Units unit) : float
{
switch (unit)
{
case Units.Grams :
return 1;
case Units.KiloGrams :
return 0.001;
case Units.MilliGrams:
return 1000;
}
//unhandled unit?
return 0;
}