diff --git a/UnitsNet.Tests/CustomCode/MassConcentrationTests.cs b/UnitsNet.Tests/CustomCode/MassConcentrationTests.cs
index 9b7f2432fa..d85b6b24bb 100644
--- a/UnitsNet.Tests/CustomCode/MassConcentrationTests.cs
+++ b/UnitsNet.Tests/CustomCode/MassConcentrationTests.cs
@@ -131,7 +131,7 @@ public static void ComponentMassFromMassConcentrationAndSolutionVolume(
var massConcentration = new MassConcentration(massConcValue, massConcUnit);
var volume = new Volume(volumeValue, volumeUnit);
- Mass massComponent = massConcentration * volume;
+ Mass massComponent = (Density)massConcentration * volume;
AssertEx.EqualTolerance(expectedMassValue, massComponent.As(expectedMassUnit), tolerance);
}
diff --git a/UnitsNet/CustomCode/Quantities/MassConcentration.extra.cs b/UnitsNet/CustomCode/Quantities/MassConcentration.extra.cs
index 569c228523..0e3db4646e 100644
--- a/UnitsNet/CustomCode/Quantities/MassConcentration.extra.cs
+++ b/UnitsNet/CustomCode/Quantities/MassConcentration.extra.cs
@@ -5,13 +5,29 @@ namespace UnitsNet
{
public partial struct MassConcentration
{
+ ///
+ /// Because Density and MassConcentration are almost the same, we can convert between them.
+ ///
+ public static implicit operator MassConcentration(Density density)
+ {
+ return From(density.ToUnit(Density.BaseUnit).Value, BaseUnit);
+ }
+
+ ///
+ /// Because Density and MassConcentration are almost the same, we can convert between them.
+ ///
+ public static explicit operator Density(MassConcentration massConcentration)
+ {
+ return Density.From(massConcentration.ToUnit(BaseUnit).Value, Density.BaseUnit);
+ }
+
///
/// Get from this using the known component .
///
///
public Molarity ToMolarity(MolarMass molecularWeight)
{
- return this / molecularWeight;
+ return (Density)this / molecularWeight;
}
///
@@ -21,7 +37,7 @@ public Molarity ToMolarity(MolarMass molecularWeight)
///
public VolumeConcentration ToVolumeConcentration(Density componentDensity)
{
- return this / componentDensity;
+ return VolumeConcentration.FromDecimalFractions((Density)this / componentDensity);
}
#region Static Methods
diff --git a/UnitsNet/CustomCode/Quantities/MassFraction.extra.cs b/UnitsNet/CustomCode/Quantities/MassFraction.extra.cs
index b7c1112740..56e9db8187 100644
--- a/UnitsNet/CustomCode/Quantities/MassFraction.extra.cs
+++ b/UnitsNet/CustomCode/Quantities/MassFraction.extra.cs
@@ -11,7 +11,7 @@ public partial struct MassFraction
/// The actual mass of the component involved in this mixture
public Mass GetComponentMass(Mass totalMass)
{
- return totalMass * this;
+ return totalMass * DecimalFractions;
}
///
@@ -21,7 +21,7 @@ public Mass GetComponentMass(Mass totalMass)
/// The total mass of the mixture
public Mass GetTotalMass(Mass componentMass)
{
- return componentMass / this;
+ return componentMass / DecimalFractions;
}
#region Static Methods
diff --git a/UnitsNet/CustomCode/Quantities/Molarity.extra.cs b/UnitsNet/CustomCode/Quantities/Molarity.extra.cs
index 32203f21f7..92be3d10d4 100644
--- a/UnitsNet/CustomCode/Quantities/Molarity.extra.cs
+++ b/UnitsNet/CustomCode/Quantities/Molarity.extra.cs
@@ -20,7 +20,7 @@ public MassConcentration ToMassConcentration(MolarMass molecularWeight)
///
public VolumeConcentration ToVolumeConcentration(Density componentDensity, MolarMass componentMass)
{
- return this * componentMass / componentDensity;
+ return VolumeConcentration.FromDecimalFractions(this * componentMass / componentDensity);
}
#region Static Methods
diff --git a/UnitsNet/CustomCode/Quantities/VolumeConcentration.extra.cs b/UnitsNet/CustomCode/Quantities/VolumeConcentration.extra.cs
index 205acf77e3..2f6fd4624a 100644
--- a/UnitsNet/CustomCode/Quantities/VolumeConcentration.extra.cs
+++ b/UnitsNet/CustomCode/Quantities/VolumeConcentration.extra.cs
@@ -43,7 +43,7 @@ public static VolumeConcentration FromVolumes(Volume componentVolume, Volume mix
///
public static VolumeConcentration FromMolarity(Molarity molarity, Density componentDensity, MolarMass componentMolarMass)
{
- return molarity * componentMolarMass / componentDensity;
+ return FromDecimalFractions(molarity * componentMolarMass / componentDensity);
}
#endregion