I have a problem calculating from double to string when I have a sum of a list. When the language setting is changed, I've tried using InvariantCulture but I've not managed to get it to work. Does anyone have any tips on how to process this?
Code looks like:
List<string> Moms_F = new List<string>();
double tot_Moms_F = Moms_F.Sum(x => Convert.ToDouble(x));
AssignControls(GetControls(wordDoc, "tot_Moms_F"), tot_Moms_F.ToString());
What I tried to to was
CultureInfo ci;
ci = (CultureInfo)CultureInfo.InvariantCulture.Clone();
ci.NumberFormat.NumberDecimalSeparator = ".";
ci.NumberFormat.NumberGroupSeparator = ".";
and then adding
double tot_Moms_F = Moms_F.Sum(x => Convert.ToDouble(ci));
but I then get the error : Unable to cast object of type 'System.Globalization.CultureInfo' to type 'System.IConvertible'.
Does anyone have a good idea?