public static void Main()
d1 = double.Parse("0.00345");
d2 = double.Parse("12654.004556");
d3 = double.Parse("23.865000000000003");
double x1 = RoundToSignificantDigits(d1, 3);
double x2 = RoundToSignificantDigits(d2, 3);
double x3 = RoundToSignificantDigits(d3, 3);
static double RoundToSignificantDigits(double d, int digits)
double scale = Math.Pow(10, Math.Floor(Math.Log10(Math.Abs(d))) + 1);
return scale * Math.Round(d / scale, digits);