Kann jemand mir helfen, den folgenden Fehler in C# zu beheben.System.FormatException: Eingabezeichenfolge war nicht in einem korrekten Format in C#
System.FormatException: Input string was not in a correct format
Unten ist der Code:
CultureInfo culture = new CultureInfo("en-US");
txtTotalPrice.Text = totalPrice.ToString("c", culture);
private void btnCheck_Click(object sender, EventArgs e)
{
// ...................................
decimal totalPrice = Convert.ToDecimal(txtTotalPrice.Text.Split(',')[0]) * 1000;
decimal finalPrice = totalPrice - (totalPrice/100) * discount;
// ......................................
}
Was ist der Inhalt von txtTotalPrice.Text in dem Moment, in dem Sie auf die Schaltfläche klicken? – Steve
https://Stackoverflow.com/a/89235/34092 – mjwills
Welche Zeile wirft die Ausnahme? – mjwills