c# - How to convert a map point string to double? -


i have string such 45,5235234096284 or 112,013574120648. want convert double. have tried following code got error 'system.globalization.cultureinfo' not contain definition 'getcultureinfo ' because of framework version. i'm not able change framework option.i have looked solution couldn't understand clearly.what best way converting these string double commas.

var convertedmappoint = double.parse(mappoint, cultureinfo.getcultureinfo(1053)); 

first, should split input on spaces, since separator:

string input = "45,5235234096284 112,013574120648"; string[] splitted = input.split(' '); 

then can iterate on result of splitting, , convert each double:

list<double> doubles = new list<double>();  foreach (string s in splitted) {     doubles.add(double.parse(s, new cultureinfo("fr-fr"))); } 

i used fr-fr, since has comma decimal separator, can use culture that.

if doesn't work you, , 100% sure there no . thousand separator, can use this:

doubles.add(double.parse(s.replace(",", "."))); 

then might want add invariant culture platform independent:

doubles.add(double.parse(s.replace(",", ".", cultureinfo.invariantculture))); 

Comments

Popular posts from this blog

How has firefox/gecko HTML+CSS rendering changed in version 38? -

javascript - Complex json ng-repeat -

jquery - Cloning of rows and columns from the old table into the new with colSpan and rowSpan -