// Parses an integer from a String in the given style. If // a NumberFormatInfo isn't specified, the current culture's // NumberFormatInfo is assumed. // /// <include file='doc\Int32.uex' path='docs/doc[@for="Int32.Parse3"]/*' /> public static int Parse(String s, NumberStyles style, IFormatProvider provider) { NumberFormatInfo info = NumberFormatInfo.GetInstance(provider); NumberFormatInfo.ValidateParseStyle(style); return(Number.ParseInt32(s, style, info)); }
public static ushort Parse(String s, NumberStyles style) { NumberFormatInfo.ValidateParseStyle(style); uint i = Number.ParseUInt32(s, style); if (i > MaxValue) { throw new OverflowException("Overflow_UInt16"); } return((ushort)i); }
// Parses an unsigned byte from a String in the given style. If // a NumberFormatInfo isn't specified, the current culture's // NumberFormatInfo is assumed. //| <include path='docs/doc[@for="Byte.Parse3"]/*' /> public static byte Parse(String s, NumberStyles style) { NumberFormatInfo.ValidateParseStyle(style); int i = Number.ParseInt32(s, style); if (i < MinValue || i > MaxValue) { throw new OverflowException("Overflow_Byte"); } return((byte)i); }
public unsafe static UIntPtr Parse(String s, NumberStyles style) { NumberFormatInfo.ValidateParseStyle(style); if (sizeof(UIntPtr) == 4) { return(Number.ParseUInt32(s, style)); } else { return(Number.ParseUInt64(s, style)); } }
public static ushort Parse(String s, NumberStyles style, IFormatProvider provider) { NumberFormatInfo info = NumberFormatInfo.GetInstance(provider); NumberFormatInfo.ValidateParseStyle(style); uint i = Number.ParseUInt32(s, style, info); if (i > MaxValue) { throw new OverflowException(Environment.GetResourceString("Overflow_UInt16")); } return((ushort)i); }
// Parses an unsigned byte from a String in the given style. If // a NumberFormatInfo isn't specified, the current culture's // NumberFormatInfo is assumed. /// <include file='doc\Byte.uex' path='docs/doc[@for="Byte.Parse3"]/*' /> public static byte Parse(String s, NumberStyles style, IFormatProvider provider) { NumberFormatInfo info = NumberFormatInfo.GetInstance(provider); NumberFormatInfo.ValidateParseStyle(style); int i = Number.ParseInt32(s, style, info); if (i < MinValue || i > MaxValue) { throw new OverflowException(Environment.GetResourceString("Overflow_Byte")); } return((byte)i); }
public static sbyte Parse(String s, NumberStyles style) { NumberFormatInfo.ValidateParseStyle(style); int i = Number.ParseInt32(s, style); if (((style & NumberStyles.AllowHexSpecifier) != 0) && (i <= Byte.MaxValue)) // We are parsing a hexadecimal number { return((sbyte)i); } if (i < MinValue || i > MaxValue) { throw new OverflowException("Overflow_SByte"); } return((sbyte)i); }
public static sbyte Parse(String s, NumberStyles style, IFormatProvider provider) { NumberFormatInfo info = NumberFormatInfo.GetInstance(provider); NumberFormatInfo.ValidateParseStyle(style); int i = Number.ParseInt32(s, style, info); if (((style & NumberStyles.AllowHexSpecifier) != 0) && (i <= Byte.MaxValue)) // We are parsing a hexadecimal number { return((sbyte)i); } if (i < MinValue || i > MaxValue) { throw new OverflowException(Environment.GetResourceString("Overflow_SByte")); } return((sbyte)i); }
//| <include path='docs/doc[@for="Int16.Parse3"]/*' /> public static short Parse(String s, NumberStyles style) { NumberFormatInfo.ValidateParseStyle(style); int i = Number.ParseInt32(s, style); // 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) && (i <= UInt16.MaxValue)) // We are parsing a hexadecimal number { return((short)i); } if (i < MinValue || i > MaxValue) { throw new OverflowException("Overflow_Int16"); } return((short)i); }
/// <include file='doc\Int32.uex' path='docs/doc[@for="Int32.Parse1"]/*' /> public static int Parse(String s, NumberStyles style) { NumberFormatInfo.ValidateParseStyle(style); return(Parse(s, style, null)); }
public static uint Parse(String s, NumberStyles style) { NumberFormatInfo.ValidateParseStyle(style); return(Number.ParseUInt32(s, style)); }
// Parses a long from a String in the given style. If // a NumberFormatInfo isn't specified, the current culture's // NumberFormatInfo is assumed. // //| <include path='docs/doc[@for="Int64.Parse3"]/*' /> public static long Parse(String s, NumberStyles style) { NumberFormatInfo.ValidateParseStyle(style); return(Number.ParseInt64(s, style)); }