코드는 .NET3.5를 대상으로 VS2008에서 컴파일됩니다. 이것은 시스템에서 재현 할 수 없습니다. 어떤 종류의 현지화 설정이 사용 중인지 의심 스럽지만 그것에 대해 많이 알지 못합니다.일부 시스템에서 System.Convert ("0")이 FormatException을 throw하는 이유는 무엇입니까?
다른 모든 유효한 숫자가 제대로 작동하는 것 같습니다. 버그는 (생산 코드를 같은 예외가 발생하지만입니다)이 코드로 설명된다 : 명령 줄에서
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication2
{
class Program
{
static void Main(string[] args)
{
string str = "";
do
{
str = Console.ReadLine();
Console.WriteLine("\t\"{0}\"", Convert.ToDouble(str));
}
while (str != null);
}
}
}
, "0"의 입력은 내가 발견 한 적어도 하나의 시스템에서 응용 프로그램을 충돌합니다. 사용자의 PC에서
스택 추적 :
System.FormatException: Input string was not in a correct format.
at System.Number.StringToNumber(String str, NumberStyles options, NumberBuffer& number, NumberFormatInfo info, Boolean parseDecimal)
at System.Number.ParseDouble(String value, NumberStyles options, NumberFormatInfo numfmt)
at System.Double.Parse(String s, NumberStyles style, NumberFormatInfo info)
at System.Convert.ToDouble(String value)
무슨 뜻입니까? 어떤 유형의 오류 메시지 나 스택 추적을 얻지 못합니까? –
맹목적으로 콘솔 입력을 이중으로 변환하고 있습니다. 'Double.TryParse()'를 먼저 사용하여 번호를 검증 해 보았습니까? –
크래시는 적절하게 처리되지 않는 예외를 의미합니다. 스택 추적을 얻지 만 사용자의 PC이므로 내 컴퓨터에서 문제를 재현 할 수 없습니다. – pomeroy