Skip to content
This repository was archived by the owner on Dec 24, 2022. It is now read-only.

Commit aa082aa

Browse files
committed
Add .ToDoubleInvariant() to convert independently on culture
1 parent 0d6a309 commit aa082aa

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

src/ServiceStack.Text/StringExtensions.cs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1007,6 +1007,11 @@ public static float ToFloat(this string text)
10071007
return text == null ? default(float) : float.Parse(text);
10081008
}
10091009

1010+
public static float ToFloatInvariant(this string text)
1011+
{
1012+
return text == null ? default(float) : float.Parse(text, CultureInfo.InvariantCulture);
1013+
}
1014+
10101015
public static float ToFloat(this string text, float defaultValue)
10111016
{
10121017
float ret;
@@ -1018,6 +1023,11 @@ public static double ToDouble(this string text)
10181023
return text == null ? default(double) : double.Parse(text);
10191024
}
10201025

1026+
public static double ToDoubleInvariant(this string text)
1027+
{
1028+
return text == null ? default(double) : double.Parse(text, CultureInfo.InvariantCulture);
1029+
}
1030+
10211031
public static double ToDouble(this string text, double defaultValue)
10221032
{
10231033
double ret;
@@ -1029,6 +1039,11 @@ public static decimal ToDecimal(this string text)
10291039
return text == null ? default(decimal) : decimal.Parse(text);
10301040
}
10311041

1042+
public static decimal ToDecimalInvariant(this string text)
1043+
{
1044+
return text == null ? default(decimal) : decimal.Parse(text, CultureInfo.InvariantCulture);
1045+
}
1046+
10321047
public static decimal ToDecimal(this string text, decimal defaultValue)
10331048
{
10341049
decimal ret;

0 commit comments

Comments
 (0)