diff --git a/source/System/Convert.cs b/source/System/Convert.cs index 3435deaa..05481d7f 100644 --- a/source/System/Convert.cs +++ b/source/System/Convert.cs @@ -28,11 +28,11 @@ public enum Base64FormattingOptions /// /// Converts a base data type to another base data type. /// - [ComponentModel.EditorBrowsableAttribute(ComponentModel.EditorBrowsableState.Never)] + [ComponentModel.EditorBrowsable(ComponentModel.EditorBrowsableState.Never)] public static class Convert { [MethodImpl(MethodImplOptions.InternalCall)] - private static extern long NativeToInt64(string value, bool signed, long min, long max, int radix); + private static extern long NativeToInt64(string value, bool signed, long min, long max, int fromBase); [MethodImpl(MethodImplOptions.InternalCall)] private static extern double NativeToDouble(string value); @@ -52,94 +52,150 @@ public static char ToChar(ushort value) /// Converts the specified string representation of a number to an equivalent 8-bit signed integer. /// /// A string that contains the number to convert. + /// The base of the number in , which must be 2, 8, 10, or 16. See remark bellow about platform support. /// An 8-bit signed integer that is equivalent to the number in value, or 0 (zero) if value is null. + /// + /// The nanoFramework implementation of this method may provide only a subset of the equivalent .NET method, + /// which is supporting only conversions for base 10 values. In that case, any call using a with a value other than 10 will throw a . + /// + /// is not 2, 8, 10, or 16. + /// If the platform doesn't have support to convert from non-base 10 values. [CLSCompliant(false)] - public static sbyte ToSByte(string value, int radix = 10) + public static sbyte ToSByte(string value, int fromBase = 10) { - return (sbyte)NativeToInt64(value, true, SByte.MinValue, SByte.MaxValue, radix); + return (sbyte)NativeToInt64(value, true, SByte.MinValue, SByte.MaxValue, fromBase); } /// /// Converts the specified string representation of a number to an equivalent 8-bit unsigned integer. /// /// A string that contains the number to convert. + /// The base of the number in , which must be 2, 8, 10, or 16. See remark bellow about platform support. /// An 8-bit unsigned integer that is equivalent to value, or zero if value is null. - public static byte ToByte(string value, int radix = 10) + /// + /// The nanoFramework implementation of this method may provide only a subset of the equivalent .NET method, + /// which is supporting only conversions for base 10 values. In that case, any call using a with a value other than 10 will throw a . + /// + /// is not 2, 8, 10, or 16. + /// If the platform doesn't have support to convert from non-base 10 values. + public static byte ToByte(string value, int fromBase = 10) { - return (byte)NativeToInt64(value, false, Byte.MinValue, Byte.MaxValue, radix); + return (byte)NativeToInt64(value, false, Byte.MinValue, Byte.MaxValue, fromBase); } /// /// Converts the specified string representation of a number to an equivalent 16-bit signed integer. /// /// A string that contains the number to convert. + /// The base of the number in , which must be 2, 8, 10, or 16. See remark bellow about platform support. /// A 16-bit signed integer that is equivalent to the number in value, or 0 (zero) if value is null. - public static short ToInt16(string value, int radix = 10) + /// + /// The nanoFramework implementation of this method may provide only a subset of the equivalent .NET method, + /// which is supporting only conversions for base 10 values. In that case, any call using a with a value other than 10 will throw a . + /// + /// is not 2, 8, 10, or 16. + /// If the platform doesn't have support to convert from non-base 10 values. + public static short ToInt16(string value, int fromBase = 10) { - return (short)NativeToInt64(value, true, Int16.MinValue, Int16.MaxValue, radix); + return (short)NativeToInt64(value, true, Int16.MinValue, Int16.MaxValue, fromBase); } /// /// Converts the specified string representation of a number to an equivalent 16-bit unsigned integer. /// /// A string that contains the number to convert. + /// The base of the number in , which must be 2, 8, 10, or 16. See remark bellow about platform support. /// A 16-bit unsigned integer that is equivalent to the number in value, or 0 (zero) if value is null. + /// + /// The nanoFramework implementation of this method may provide only a subset of the equivalent .NET method, + /// which is supporting only conversions for base 10 values. In that case, any call using a with a value other than 10 will throw a . + /// + /// is not 2, 8, 10, or 16. + /// If the platform doesn't have support to convert from non-base 10 values. [CLSCompliant(false)] - public static ushort ToUInt16(string value, int radix = 10) + public static ushort ToUInt16(string value, int fromBase = 10) { - return (ushort)NativeToInt64(value, false, UInt16.MinValue, UInt16.MaxValue, radix); + return (ushort)NativeToInt64(value, false, UInt16.MinValue, UInt16.MaxValue, fromBase); } /// /// Converts the specified string representation of a number to an equivalent 32-bit signed integer. /// /// A string that contains the number to convert. + /// The base of the number in , which must be 2, 8, 10, or 16. See remark bellow about platform support. /// A 32-bit signed integer that is equivalent to the number in value, or 0 (zero) if value is null. - public static int ToInt32(string value, int radix = 10) + /// + /// The nanoFramework implementation of this method may provide only a subset of the equivalent .NET method, + /// which is supporting only conversions for base 10 values. In that case, any call using a with a value other than 10 will throw a . + /// + /// is not 2, 8, 10, or 16. + /// If the platform doesn't have support to convert from non-base 10 values. + public static int ToInt32(string value, int fromBase = 10) { - return (int)NativeToInt64(value, true, Int32.MinValue, Int32.MaxValue, radix); + return (int)NativeToInt64(value, true, Int32.MinValue, Int32.MaxValue, fromBase); } /// /// Converts the specified string representation of a number to an equivalent 32-bit unsigned integer. /// /// A string that contains the number to convert. + /// The base of the number in , which must be 2, 8, 10, or 16. See remark bellow about platform support. /// A 32-bit unsigned integer that is equivalent to the number in value, or 0 (zero) if value is null. + /// + /// The nanoFramework implementation of this method may provide only a subset of the equivalent .NET method, + /// which is supporting only conversions for base 10 values. In that case, any call using a with a value other than 10 will throw a . + /// + /// is not 2, 8, 10, or 16. + /// If the platform doesn't have support to convert from non-base 10 values. [CLSCompliant(false)] - public static uint ToUInt32(string value, int radix = 10) + public static uint ToUInt32(string value, int fromBase = 10) { - return (uint)NativeToInt64(value, false, UInt32.MinValue, UInt32.MaxValue, radix); + return (uint)NativeToInt64(value, false, UInt32.MinValue, UInt32.MaxValue, fromBase); } /// /// Converts the specified string representation of a number to an equivalent 64-bit signed integer. /// /// A string that contains a number to convert. + /// The base of the number in , which must be 2, 8, 10, or 16. See remark bellow about platform support. /// A 64-bit signed integer that is equivalent to the number in value, or 0 (zero) if value is null. - public static long ToInt64(string value, int radix = 10) + /// + /// The nanoFramework implementation of this method may provide only a subset of the equivalent .NET method, + /// which is supporting only conversions for base 10 values. In that case, any call using a with a value other than 10 will throw a . + /// + /// is not 2, 8, 10, or 16. + /// If the platform doesn't have support to convert from non-base 10 values. /// Converts the specified string representation of a number to an equivalent 64-bit unsigned integer. /// /// A string that contains the number to convert. + /// The base of the number in , which must be 2, 8, 10, or 16. See remark bellow about platform support. /// A 64-bit signed integer that is equivalent to the number in value, or 0 (zero) if value is null. + /// + /// The nanoFramework implementation of this method may provide only a subset of the equivalent .NET method, + /// which is supporting only conversions for base 10 values. In that case, any call using a with a value other than 10 will throw a . + /// + /// is not 2, 8, 10, or 16. + /// If the platform doesn't have support to convert from non-base 10 values. [CLSCompliant(false)] - public static ulong ToUInt64(string value, int radix = 10) + public static ulong ToUInt64(string value, int fromBase = 10) { - return (ulong)NativeToInt64(value, true, 0, 0, radix); + return (ulong)NativeToInt64(value, true, 0, 0, fromBase); } /// /// Converts the specified string representation of a number to an equivalent double-precision floating-point number. /// - /// A string that contains the number to convert. + /// A string that contains the number to convert. /// A double-precision floating-point number that is equivalent to the number in value, or 0 (zero) if value is null. - public static double ToDouble(string s) + public static double ToDouble(string value) { - return NativeToDouble(s); + return NativeToDouble(value); } ///