Int16.cs 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. //
  2. // System.Int16.cs
  3. //
  4. // Author:
  5. // Miguel de Icaza ([email protected])
  6. //
  7. // (C) Ximian, Inc. http://www.ximian.com
  8. //
  9. using System.Globalization;
  10. namespace System {
  11. public struct Int16 : IComparable, IFormattable { //, IConvertible {
  12. public const short MaxValue = 32767;
  13. public const short MinValue = -32768;
  14. // VES needs to know about value. public is workaround
  15. // so source will compile
  16. public short value;
  17. public int CompareTo (object v)
  18. {
  19. if (!(v is System.Int16))
  20. throw new ArgumentException ("Value is not a System.Int16");
  21. return value - ((short) v);
  22. }
  23. public override bool Equals (object o)
  24. {
  25. if (!(o is System.Int16))
  26. return false;
  27. return ((short) o) == value;
  28. }
  29. public override int GetHashCode ()
  30. {
  31. return value;
  32. }
  33. public static short Parse (string s)
  34. {
  35. return Parse (s, NumberStyles.Integer, null);
  36. }
  37. public static short Parse (string s, IFormatProvider fp)
  38. {
  39. return Parse (s, NumberStyles.Integer, fp);
  40. }
  41. public static short Parse (string s, NumberStyles style)
  42. {
  43. return Parse (s, style, null);
  44. }
  45. public static short Parse (string s, NumberStyles style, IFormatProvider fp)
  46. {
  47. // TODO: Implement me
  48. return 0;
  49. }
  50. public override string ToString ()
  51. {
  52. return ToString ("G", null);
  53. }
  54. public string ToString (IFormatProvider fp)
  55. {
  56. return ToString ("G", fp);
  57. }
  58. public string ToString (string format)
  59. {
  60. return ToString (format, null);
  61. }
  62. public string ToString (string format, IFormatProvider fp)
  63. {
  64. // TODO: Implement me.
  65. return "";
  66. }
  67. // =========== IConvertible Methods =========== //
  68. public TypeCode GetTypeCode ()
  69. {
  70. return TypeCode.Int16;
  71. }
  72. }
  73. }