-
Notifications
You must be signed in to change notification settings - Fork 408
Closed
Description
I would like to split up the code responsible for unit conversion and ToString.
Since we have the ToUnit method, we could simplify the ToString implementations and implement IFormattable.
This would leave the following ToString overloads:
public override string ToString();
public string ToString(string format);
public string ToString(IFormatProvider provider);
public string ToString(string format, IFormatProvider provider);For example to get a length string in inches, we currently do the following:
var length = Length.FromMeters( 3.0 );
var lengthInInchesString = length.ToString( LengthUnit.Inch );Today, this will achieve the same thing
var length = Length.FromMeters( 3.0 );
var lengthInInchesString = length.ToUnit( LengthUnit.Inch ).ToString();We could even change the conversion properties to return a converted quantity rather than a double (public Length Inches in this example) and do the following:
var length = Length.FromMeters( 3.0 );
var lengthInInchesString = length.Inches.ToString();Metadata
Metadata
Assignees
Labels
No labels