2002-07-10 Gonzalo Paniagua Javier <gonzalo@ximian.com>
[mono.git] / mcs / class / corlib / System / Object.cs
1 //
2 // System.Object.cs
3 //
4 // Author:
5 //   Miguel de Icaza (miguel@ximian.com)
6 //
7 // (C) Ximian, Inc.  http://www.ximian.com
8 //
9 //
10
11 using System.Runtime.CompilerServices;
12
13 namespace System {
14
15         public class Object {
16
17                 // <summary>
18                 //   Compares this object to the specified object.
19                 //   Returns true if they are equal, false otherwise.
20                 // </summary>
21                 public virtual bool Equals (object o)
22                 {
23                         return this == o;
24                 }
25
26                 // <summary>
27                 //   Compares two objects for equality
28                 // </summary>
29                 public static bool Equals (object a, object b)
30                 {
31                         if (a == b)
32                                 return true;
33                         
34                         if (a == null || b == null)
35                                 return false;
36
37                         return a.Equals (b);
38                 }
39
40                 // <summary>
41                 //   Initializes a new instance of the object class.
42                 // </summary>
43                 public Object ()
44                 {
45                 }
46
47                 // <summary>
48                 //   Object destructor. 
49                 // </summary>
50                 ~Object ()
51                 {
52                 }
53
54                 // <summary>
55                 //   Returns a hashcode for this object.  Each derived
56                 //   class should return a hash code that makes sense
57                 //   for that particular implementation of the object.
58                 // </summary>
59                 [MethodImplAttribute(MethodImplOptions.InternalCall)]
60                 public extern virtual int GetHashCode ();
61
62                 // <summary>
63                 //   Returns the Type associated with the object.
64                 // </summary>
65                 [MethodImplAttribute(MethodImplOptions.InternalCall)]
66                 public extern Type GetType ();
67
68                 // <summary>
69                 //   Shallow copy of the object.
70                 // </summary>
71                 [MethodImplAttribute(MethodImplOptions.InternalCall)]
72                 protected extern object MemberwiseClone ();
73
74                 // <summary>
75                 //   Returns a stringified representation of the object.
76                 //   This is not supposed to be used for user presentation,
77                 //   use Format() for that and IFormattable.
78                 //
79                 //   ToString is mostly used for debugging purposes. 
80                 // </summary>
81                 public virtual string ToString ()
82                 {
83                         return GetType().FullName;
84                 }
85
86                 // <summary>
87                 //   Tests whether a is equal to b.
88                 //   Can not figure out why this even exists
89                 // </summary>
90                 public static bool ReferenceEquals (object a, object b)
91                 {
92                         return (a == b);
93                 }
94
95                 [MethodImplAttribute(MethodImplOptions.InternalCall)]
96                 internal extern IntPtr obj_address ();
97  
98                 void FieldGetter (string typeName, string fieldName, ref object val)
99                 {
100                         /* never called */
101                 }
102
103                 void FieldSetter (string typeName, string fieldName, object val)
104                 {
105                         /* never called */
106                 }
107         }
108 }