runtime: .Net 5.0 Int.Parse fails parsing with negative values.
.Net 5.0 Preview 7, fails on Int.Parse(“-1”) with Message: System.FormatException : Input string was not in a correct format. Stack Trace: Number.ThrowOverflowOrFormatException(ParsingStatus status, TypeCode type) Number.ParseInt32(ReadOnlySpan`1 value, NumberStyles styles, NumberFormatInfo info) Int32.Parse(String s) NetCore50prev7_Tests.NegativeIntegerFailsParse() line 15
public class NetCore50prev7_Tests { [Fact] public void NegativeIntegerFailsParse() { int.Parse(“-1”); } }
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Reactions: 1
- Comments: 15 (11 by maintainers)
@eriksimonic as a workaround you can define an env. variable
DOTNET_SYSTEM_GLOBALIZATION_USENLS=true
to rely on NLS instead of ICU on Windows.@eriksimonic what is the current culture?
and OS?
You could also write a method that tries both