5 // Miguel de Icaza (miguel@ximian.com)
7 // (C) Ximian, Inc. http://www.ximian.com
10 using System.Globalization;
15 public struct UInt32 : IComparable, IFormattable { //, IConvertible {
16 public static Type Type = typeof (uint);
18 public const uint MaxValue = 0xffffffff;
19 public const uint MinValue = 0;
23 public int CompareTo (object v)
28 if (!(v is System.UInt32))
29 throw new ArgumentException (Locale.GetText ("Value is not a System.UInt32"));
31 if (value == (uint) v)
40 public override bool Equals (object o)
42 if (!(o is System.UInt32))
45 return ((uint) o) == value;
48 public override int GetHashCode ()
53 public static uint Parse (string s)
58 bool digits_seen = false;
61 throw new ArgumentNullException (Locale.GetText ("s is null"));
66 for (i = 0; i < len; i++){
68 if (!Char.IsWhiteSpace (c))
73 throw new FormatException ();
81 if (c >= '0' && c <= '9'){
82 uint d = (uint) (c - '0');
84 val = checked (val * 10 + d);
87 if (Char.IsWhiteSpace (c)){
88 for (i++; i < len; i++){
89 if (!Char.IsWhiteSpace (s [i]))
90 throw new FormatException ();
94 throw new FormatException ();
98 throw new FormatException ();
104 public static uint Parse (string s, IFormatProvider fp)
106 return Parse (s, NumberStyles.Integer, fp);
109 public static uint Parse (string s, NumberStyles style)
111 return Parse (s, style, null);
114 public static uint Parse (string s, NumberStyles style, IFormatProvider fp)
116 // TODO: Implement me
117 throw new NotImplementedException ();
120 public override string ToString ()
122 return ToString ("G", null);
125 public string ToString (IFormatProvider fp)
127 return ToString ("G", fp);
130 public string ToString (string format)
132 return ToString (format, null);
135 public string ToString (string format, IFormatProvider fp)
138 NumberFormatInfo nfi;
140 fmt = (format == null) ? "G" : format;
143 nfi = NumberFormatInfo.CurrentInfo;
145 nfi = (NumberFormatInfo) fp.GetFormat (Type);
148 nfi = NumberFormatInfo.CurrentInfo;
151 return IntegerFormatter.NumberToString (fmt, nfi, value);
154 // =========== IConvertible Methods =========== //
156 public TypeCode GetTypeCode ()
158 return TypeCode.UInt32;