private double Conversion(string MeasurementType, string conversionType, double value) { Length length = new Length(); Weights weights = new Weights(); Volumes volume = new Volumes(); Temperature temperature = new Temperature(); if (MeasurementType == "length") { LengthUnit unit = length.SetUnitAndConvertLength(conversionType); if (unit == LengthUnit.FeetToInch || unit == LengthUnit.YardToInch || unit == LengthUnit.CentimeterToInch) { return(length.ConvertLength(unit, value)); } } if (MeasurementType == "weight") { WeightsUnit unit = weights.SetUnitAndConvertWeights(conversionType); if (unit.Equals(WeightsUnit.KilogramToGrams) || unit.Equals(WeightsUnit.TonneToKilograms)) { return(weights.ConvertWeigths(unit, value)); } } if (MeasurementType == "volume") { VolumeUnit unit = volume.SetUnitAndConvertVolume(conversionType); if (unit.Equals(VolumeUnit.GallonToLiter) || unit.Equals(VolumeUnit.LiterToMilliliter) || unit.Equals(VolumeUnit.MilliliterToLiter)) { return(volume.ConvertVolumes(unit, value)); } } if (MeasurementType == "temperature") { TemperatureUnit unit = temperature.SetUnitAndConvertTemperature(conversionType); if (unit.Equals(TemperatureUnit.CelsiusToFahrenheit)) { return(temperature.ConvertTemperature(unit, value)); } } return(value); }