if (originalString.IndexOf(",") > 0 && originalString.IndexOf(".") > originalString.IndexOf(","))
{
cleanedString = originalString.Replace(",", "").Replace(".", ",");
}
else if (originalString.IndexOf(".") > 0 && originalString.IndexOf(",") > originalString.IndexOf("."))
{
cleanedString = originalString.Replace(".", "");
}
else if (originalString.IndexOf(",") == -1 && originalString.IndexOf(".") > 0)
{
cleanedString = originalString.Replace(".", ",");
}
else
{
cleanedString = originalString; //cleanedString =4,5
}
return Convert.ToDecimal(cleanedString);
Becuse your "else" never run. Try this if-else combination
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…