Won't convert string to decimal c# (Input string was not in a correct format.)

c#, decimal, string

Solution

It's likely your current culture doesn't use `.` as a decimal separator. Try specifying the invariant culture when you parse the string:

using System.Globalization;

...

string test = "123.95";
decimal test1 = decimal.Parse(test, CultureInfo.InvariantCulture); 

Alternatively, you could specify a culture that uses the specific format you want:

string test = "123.95";
var culture = new CultureInfo("en-US");
decimal test1 = decimal.Parse(test, culture); 

Problem

Visual studio wont convert my string to decimal Error: Input string was not in a correct format. Code: ``` string test = "123.95"; decimal test1 = decimal.parse(test); // string being an int "123" doesnt cause this ``` also Convert.toDecimal(test); does just the same. EDIT: Thanks for the answers, I was looking online for how decimals worked and everyone were using '.' and not ','. Sorry about how incredibly stupid I and this post is. And thanks again for the answeres :)

Original source