5 // Miguel de Icaza (miguel@ximian.com)
7 // (C) Ximian, Inc. http://www.ximian.com
10 using System.Globalization;
15 public struct SByte : IComparable, IFormattable { //, IConvertible {
16 public static Type Type = typeof (sbyte);
18 public const sbyte MinValue = -128;
19 public const sbyte MaxValue = 127;
21 // VES needs to know about value. public is workaround
22 // so source will compile
25 public int CompareTo (object v)
27 if (v == null || !(v is System.SByte))
28 throw new ArgumentException (Locale.GetText ("Value is not a System.SByte"));
30 return value - ((sbyte) v);
33 public override bool Equals (object o)
35 if (!(o is System.SByte))
38 return ((sbyte) o) == value;
41 public override int GetHashCode ()
46 public static sbyte Parse (string s)
48 return Parse (s, NumberStyles.Integer, null);
51 public static sbyte Parse (string s, IFormatProvider fp)
53 return Parse (s, NumberStyles.Integer, fp);
56 public static sbyte Parse (string s, NumberStyles style)
58 return Parse (s, style, null);
61 public static sbyte Parse (string s, NumberStyles style, IFormatProvider fp)
64 throw new NotImplementedException ();
67 public override string ToString ()
69 return ToString ("G", null);
72 public string ToString (IFormatProvider fp)
74 return ToString ("G", fp);
77 public string ToString (string format)
79 return ToString (format, null);
82 public string ToString (string format, IFormatProvider fp)
87 fmt = (format == null) ? "G" : format;
90 nfi = NumberFormatInfo.CurrentInfo;
92 nfi = (NumberFormatInfo) fp.GetFormat (Type);
95 nfi = NumberFormatInfo.CurrentInfo;
98 return IntegerFormatter.NumberToString (fmt, nfi, value);
101 // =========== ICovnertible Methods =========== //
103 public TypeCode GetTypeCode ()
105 return TypeCode.Byte;