Windows Presentation Foundation
A part of the .NET Framework that provides a unified programming model for building line-of-business desktop applications on Windows.
2,760 questions
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
Hallo zusammen,
In meinem einen C# Projekt funktioniert das double Tage_double = Convert.ToDouble(Tage_string);
problemlos und im anderen Projekt funktioniert es nicht obwohl ich den Code kopiert habe.
Kann mir jemand helfen?
Mit freundlichen Grüssen
RobinJ
Hi Robin,
try following console demo:
using System;
using System.Globalization;
using System.Windows.Forms;
namespace ConsoleApp1
{
class Program28
{
static void Main(string[] args)
{
try
{
(new Demo()).Execute();
}
catch (Exception ex) { Console.WriteLine(ex.ToString()); }
Console.WriteLine("Continue enter key");
Console.ReadKey();
}
internal class Demo
{
internal void Execute()
{
string Tage_string = "1,234,567.89";
// english OS
Application.CurrentCulture = CultureInfo.InvariantCulture;
try
{
double Tage_double = Convert.ToDouble(Tage_string);
Console.WriteLine(Tage_double);
}
catch (Exception ex) { Console.WriteLine(ex.Message); }
// german OS
Application.CurrentCulture = CultureInfo.GetCultureInfo("de-de");
try
{
double Tage_double = Convert.ToDouble(Tage_string);
Console.WriteLine(Tage_double);
}
catch (Exception ex) { Console.WriteLine(ex.Message); }
// german OS with IFormatProvider
Application.CurrentCulture = CultureInfo.GetCultureInfo("de-de");
try
{
double Tage_double = Convert.ToDouble(Tage_string, CultureInfo.InvariantCulture);
Console.WriteLine(Tage_double);
}
catch (Exception ex) { Console.WriteLine(ex.Message); }
}
}
}
}