I am developing a unit converter for my semester project. I need some help on the structure of the classes/interfaces/abstract classes. I want some interface or abstract class that can be inherited by classes (DegreesConverter, MassConverter, LenghtConverter). Like maybe interface IUnitConvert<Type>. I will be dealing with units of angles (degrees, radians, gradians), force (newtons, pascals) and data (byte, kilobyte, megabyte, gigabyte, terabyte) for starters. Any suggestions?
I am developing a unit converter for my semester project. I need some help
Share
The first which comes to mind is to have something like System.TimeSpan where the same class represents time and you access it in different units via properties.
You would store the value internally in some constant unit (presumably SI) and convert it in the property getter / setter:
Or you can create classes for each unit:
which is used like