public static bool TryParse(String s, NumberStyles style, IFormatProvider provider, out SByte result) { UInt32.ValidateParseStyleInteger(style); result = 0; int i; if (!FormatProvider.TryParseInt32(s, style, provider, out i)) { return(false); } if ((style & NumberStyles.AllowHexSpecifier) != 0) { // We are parsing a hexadecimal number if ((i < 0) || i > Byte.MaxValue) { return(false); } result = (sbyte)i; return(true); } if (i < MinValue || i > MaxValue) { return(false); } result = (sbyte)i; return(true); }
public static sbyte Parse(String s, NumberStyles style, IFormatProvider provider) { UInt32.ValidateParseStyleInteger(style); int i = 0; try { i = FormatProvider.ParseInt32(s, style, provider); } catch (OverflowException e) { throw new OverflowException(SR.Overflow_SByte, e); } if ((style & NumberStyles.AllowHexSpecifier) != 0) { // We are parsing a hexadecimal number if ((i < 0) || i > Byte.MaxValue) { throw new OverflowException(SR.Overflow_SByte); } return((sbyte)i); } if (i < MinValue || i > MaxValue) { throw new OverflowException(SR.Overflow_SByte); } return((sbyte)i); }
public static bool TryParse(String s, NumberStyles style, IFormatProvider provider, out Int16 result) { UInt32.ValidateParseStyleInteger(style); result = 0; int i; if (!FormatProvider.TryParseInt32(s, style, provider, out i)) { return(false); } // We need this check here since we don't allow signs to specified in hex numbers. So we fixup the result // for negative numbers if ((style & NumberStyles.AllowHexSpecifier) != 0) { // We are parsing a hexadecimal number if ((i < 0) || i > UInt16.MaxValue) { return(false); } result = (Int16)i; return(true); } if (i < MinValue || i > MaxValue) { return(false); } result = (Int16)i; return(true); }
public static short Parse(String s, NumberStyles style, IFormatProvider provider) { UInt32.ValidateParseStyleInteger(style); int i = 0; try { i = FormatProvider.ParseInt32(s, style, provider); } catch (OverflowException e) { throw new OverflowException(SR.Overflow_Int16, e); } // We need this check here since we don't allow signs to specified in hex numbers. So we fixup the result // for negative numbers if ((style & NumberStyles.AllowHexSpecifier) != 0) { // We are parsing a hexadecimal number if ((i < 0) || (i > UInt16.MaxValue)) { throw new OverflowException(SR.Overflow_Int16); } return((short)i); } if (i < MinValue || i > MaxValue) { throw new OverflowException(SR.Overflow_Int16); } return((short)i); }
public static bool TryParse(String s, NumberStyles style, IFormatProvider provider, out UInt16 result) { UInt32.ValidateParseStyleInteger(style); result = 0; UInt32 i; if (!FormatProvider.TryParseUInt32(s, style, provider, out i)) { return(false); } if (i > MaxValue) { return(false); } result = (UInt16)i; return(true); }
public static bool TryParse(String s, NumberStyles style, IFormatProvider provider, out Byte result) { UInt32.ValidateParseStyleInteger(style); result = 0; int i; if (!FormatProvider.TryParseInt32(s, style, provider, out i)) { return(false); } if (i < MinValue || i > MaxValue) { return(false); } result = (byte)i; return(true); }
public static ushort Parse(String s, NumberStyles style, IFormatProvider provider) { UInt32.ValidateParseStyleInteger(style); uint i = 0; try { i = FormatProvider.ParseUInt32(s, style, provider); } catch (OverflowException e) { throw new OverflowException(SR.Overflow_UInt16, e); } if (i > MaxValue) { throw new OverflowException(SR.Overflow_UInt16); } return((ushort)i); }
public static byte Parse(String s, NumberStyles style, IFormatProvider provider) { UInt32.ValidateParseStyleInteger(style); int i = 0; try { i = FormatProvider.ParseInt32(s, style, provider); } catch (OverflowException e) { throw new OverflowException(SR.Overflow_Byte, e); } if (i < MinValue || i > MaxValue) { throw new OverflowException(SR.Overflow_Byte); } return((byte)i); }
public static bool TryParse(String s, NumberStyles style, IFormatProvider provider, out Int32 result) { UInt32.ValidateParseStyleInteger(style); return(FormatProvider.TryParseInt32(s, style, provider, out result)); }
public static int Parse(String s, NumberStyles style, IFormatProvider provider) { UInt32.ValidateParseStyleInteger(style); return(FormatProvider.ParseInt32(s, style, provider)); }
public static ushort Parse(String s, NumberStyles style) { UInt32.ValidateParseStyleInteger(style); return(Parse(s, style, null)); }
public static ulong Parse(String s, NumberStyles style) { UInt32.ValidateParseStyleInteger(style); return(FormatProvider.ParseUInt64(s, style, null)); }