2010-03-31 Miguel de Icaza <miguel@novell.com>
[mono.git] / mcs / class / corlib / System / UInt32.cs
index 553c76af586bdbd9c202252cd663fd6c5d63e312..950f1e8ea69fdcd0ad299fcb89d77ba8170216c0 100644 (file)
@@ -34,13 +34,8 @@ namespace System
 {
        [Serializable]
        [CLSCompliant (false)]
-#if NET_2_0
        [System.Runtime.InteropServices.ComVisible (true)]
-#endif
-       public struct UInt32 : IFormattable, IConvertible, IComparable
-#if NET_2_0
-               , IComparable<UInt32>, IEquatable <UInt32>
-#endif
+       public struct UInt32 : IFormattable, IConvertible, IComparable, IComparable<UInt32>, IEquatable <UInt32>
        {
                public const uint MaxValue = 0xffffffff;
                public const uint MinValue = 0;
@@ -55,13 +50,12 @@ namespace System
                        if (!(value is System.UInt32))
                                throw new ArgumentException (Locale.GetText ("Value is not a System.UInt32."));
 
-                       if (this.m_value == (uint) value)
-                               return 0;
+                       uint val = (uint) value;
 
-                       if (this.m_value < (uint) value)
-                               return -1;
+                       if (m_value == val)
+                               return 0;
 
-                       return 1;
+                       return (m_value < val) ? -1 : 1;
                }
 
                public override bool Equals (object obj)
@@ -77,7 +71,6 @@ namespace System
                        return (int) m_value;
                }
 
-#if NET_2_0
                public int CompareTo (uint value)
                {
                        if (m_value == value)
@@ -88,11 +81,10 @@ namespace System
                                return -1;
                }
 
-               public bool Equals (uint value)
+               public bool Equals (uint obj)
                {
-                       return value == m_value;
+                       return obj == m_value;
                }
-#endif
 
                internal static bool Parse (string s, bool tryParse, out uint result, out Exception exc)
                {
@@ -186,12 +178,12 @@ namespace System
                                return false;
                        }
 
-                       NumberFormatInfo nfi;
+                       NumberFormatInfo nfi = null;
                        if (provider != null) {
                                Type typeNFI = typeof (NumberFormatInfo);
                                nfi = (NumberFormatInfo) provider.GetFormat (typeNFI);
                        }
-                       else
+                       if (nfi == null)
                                nfi = Thread.CurrentThread.CurrentCulture.NumberFormat;
 
                        if (!Int32.CheckStyle (style, tryParse, ref exc))
@@ -409,12 +401,12 @@ namespace System
                }
 
                [CLSCompliant (false)]
-               public static uint Parse (string s, NumberStyles style, IFormatProvider fp
+               public static uint Parse (string s, NumberStyles style, IFormatProvider provider
                {
                        Exception exc;
                        uint res;
 
-                       if (!Parse (s, style, fp, false, out res, out exc))
+                       if (!Parse (s, style, provider, false, out res, out exc))
                                throw exc;
 
                        return res;
@@ -432,7 +424,6 @@ namespace System
                        return Parse (s, style, null);
                }
 
-#if NET_2_0
                [CLSCompliant (false)]
                public static bool TryParse (string s, out uint result) 
                {
@@ -456,7 +447,6 @@ namespace System
 
                        return true;
                }
-#endif
 
                public override string ToString ()
                {
@@ -473,9 +463,9 @@ namespace System
                        return ToString (format, null);
                }
 
-               public string ToString (string format, IFormatProvider fp)
+               public string ToString (string format, IFormatProvider provider)
                {
-                       return NumberFormatter.NumberToString (format, m_value, fp);
+                       return NumberFormatter.NumberToString (format, m_value, provider);
                }
 
                // =========== IConvertible Methods =========== //
@@ -539,9 +529,12 @@ namespace System
                        return System.Convert.ToSingle (m_value);
                }
 
-               object IConvertible.ToType (Type conversionType, IFormatProvider provider)
+               object IConvertible.ToType (Type targetType, IFormatProvider provider)
                {
-                       return System.Convert.ToType (m_value, conversionType, provider);
+                       if (targetType == null)
+                               throw new ArgumentNullException ("targetType");
+                       
+                       return System.Convert.ToType (m_value, targetType, provider, false);
                }
 
                ushort IConvertible.ToUInt16 (IFormatProvider provider)