Type System.Threading.Thread

extends System.Object

Variables:

public static System.Threading.Thread CurrentThread

public System.Boolean IsAlive

public System.Boolean IsBackground

public System.String Name

public System.Threading.ThreadPriority Priority

public System.Threading.ThreadState ThreadState

Constructors:

public System.Threading.Thread(System.Threading.ThreadStart start)

Constructs and initializes a new instance of the System.Threading.Thread class.

Parameter start: A System.Threading.ThreadStart delegate that references the methods to be invoked when the new thread begins executing.

Throws: : start is null .

Functions:

public System.Void Abort(System.Object stateInfo)

Raises a System.Threading.ThreadAbortException in the thread on which it is invoked to begin the process of terminating the thread. In all but the most extraordinary situations, calling this method will terminate the thread.

Parameter stateInfo: A System.Object that contains application-specific information

Throws: :

The object passed as the stateInfo parameter can be obtained by accessing the System.Threading.ThreadAbortException.ExceptionState property. For details on aborting threads, see System.Threading.Thread.Abort(System.Object) ().

public System.Void Abort()

Raises a System.Threading.ThreadAbortException in the thread on which it is invoked to begin the process of terminating the thread. In all but the most extraordinary situations, calling this method will terminate the thread.

Throws: :

When this method is invoked on a thread, the system throws a System.Threading.ThreadAbortException in the thread to abort it. Invoking System.Threading.Thread.Abort(System.Object) on a thread is similar to arranging for the target thread to throw a System.Threading.ThreadAbortException. Because, unlike other exceptions, a System.Threading.ThreadAbortException is sent to another thread, the exception might be delayed. A System.Threading.ThreadAbortException is required to be delayed if and while the target thread is executing any of the following: A thread abort proceeds as follows: Unexecuted finally blocks are executed before the thread is aborted; this includes any finally block that is executing when the exception is thrown. The thread is not guaranteed to abort immediately, or at all. This situation can occur if a thread does an unbounded amount of computation in the finally blocks that are called as part of the abort procedure, thereby indefinitely delaying the abort. To ensure a thread has aborted, invoke System.Threading.Thread.Join on the thread after calling System.Threading.Thread.Abort(System.Object) . If System.Threading.Thread.Abort(System.Object) is called on a thread that has not been started, the thread aborts when System.Threading.Thread.Start is called. If the target thread is blocked or sleeping in managed code and is not inside any of the code blocks that are required to delay an abort, the thread is resumed and immediately aborted. After System.Threading.Thread.Abort(System.Object) is invoked on a thread, the state of the thread includes System.Threading.ThreadState.AbortRequested. After the thread has terminated as a result of a successful call to System.Threading.Thread.Abort(System.Object), the state of the thread includes System.Threading.ThreadState.Stopped and System.Threading.ThreadState.Aborted . With sufficient permissions, a thread that is the target of a System.Threading.Thread.Abort(System.Object) can cancel the abort using the System.Threading.Thread.ResetAbort method. For an example that demonstrates calling the System.Threading.Thread.ResetAbort method, see System.Threading.ThreadAbortException .

public System.Void Finalize()

Releases the resources held by this instance.

Application code does not call this method; it is automatically invoked during garbage collection.

public static System.AppDomain GetDomain()

Returns an object representing the application domain in which the current thread is executing.

Returns: A System.AppDomain object that represents the current application domain.

public System.Void Join()

Blocks the calling thread until the thread on which this method is invoked terminates.

Throws: : The caller attempted to join a thread that is in the System.Threading.ThreadState.Unstarted state.

Use this method to ensure a thread has terminated. The caller will block indefinitely if the thread does not terminate. System.Threading.Thread.Join cannot be invoked on a thread that is in the System.Threading.ThreadState.Unstarted state. This method changes the state of the calling thread to include System.Threading.ThreadState.WaitSleepJoin.

public System.Boolean Join(System.TimeSpan timeout)

Blocks the calling thread until the thread on which this method is invoked terminates or the specified time elapses.

Parameter timeout: A System.TimeSpan set to the amount of time to wait for the thread to terminate. Specify System.Threading.Timeout.Infinite milliseconds to wait indefinitely.

Returns: true if the thread has terminated; false if the thread has not terminated after the amount of time specified by timeout has elapsed.

Throws: : The value of timeout is negative and is not equal to System.Threading.Timeout.Infinite milliseconds, or is greater than System.Int32.MaxValue milliseconds.

Throws: : The caller attempted to join a thread that is in the System.Threading.ThreadState.Unstarted state.

This method converts timeout to milliseconds, tests the validity of the converted value, and calls System.Threading.Thread.Join(System.Int32). If System.Threading.Timeout.Infinite milliseconds is specified for timeout, this method behaves identically to Join (), except for the return value. Join cannot be invoked on a thread that is in the System.Threading.ThreadState.Unstarted state. This method changes the state of the current thread to include System.Threading.ThreadState.WaitSleepJoin.

public System.Boolean Join(System.Int32 millisecondsTimeout)

Blocks the calling thread until the thread on which this method is invoked terminates or the specified time elapses.

Parameter millisecondsTimeout: A System.Int32 containing the number of milliseconds to wait for the thread to terminate.

Returns: true if the thread has terminated; false if the thread has not terminated after millisecondsTimeout has elapsed.

Throws: : The value of millisecondsTimeout is negative and is not equal to System.Threading.Timeout.Infinite .

Throws: : The caller attempted to join a thread that is in the System.Threading.ThreadState.Unstarted state.

If System.Threading.Timeout.Infinite is specified for millisecondsTimeout, this method behaves identically to Join (), except for the return value. Join cannot be invoked on a thread that is in the System.Threading.ThreadState.Unstarted state. This method changes the state of the calling thread to include System.Threading.ThreadState.WaitSleepJoin.

public static System.Void MemoryBarrier()

Guarantees that all subsequent loads or stores from the current thread will not access memory until after all previous loads and stores from the current thread have completed, as observed from this or other threads.

public static System.Void ResetAbort()

Cancels a System.Threading.Thread.Abort(System.Object) requested for the current thread.

Throws: : System.Threading.Thread.Abort(System.Object) was not invoked on the current thread.

Throws: :

This method cannot be called by untrusted code. When a call is made to System.Threading.Thread.Abort(System.Object) to destroy a thread, the system throws a System.Threading.ThreadAbortException. System.Threading.ThreadAbortException is a special exception that can be caught by application code, but is rethrown at the end of the catch block unless ResetAbort is called. ResetAbort cancels the request to abort, and prevents the ThreadAbortException from terminating the thread.

Example:

For an example that demonstrates calling this method, see System.Threading.ThreadAbortException .

public static System.Void Sleep(System.Int32 millisecondsTimeout)

Blocks the current thread for the specified number of milliseconds.

Parameter millisecondsTimeout: A System.Int32 containing the number of milliseconds for which the thread is blocked. Specify zero to indicate that this thread should be suspended temporarily to allow other waiting threads to execute. Specify System.Threading.Timeout.Infinite to block the thread indefinitely.

Throws: : The value of millisecondsTimeout is negative and is not equal to System.Threading.Timeout.Infinite .

The thread will not be scheduled for execution by the operating system for the amount of time specified. This method changes the state of the thread to include System.Threading.ThreadState.WaitSleepJoin.

public static System.Void Sleep(System.TimeSpan timeout)

Blocks the current thread for a specified time.

Parameter timeout: A System.TimeSpan set to the amount of time for which the current thread will be blocked. Specify zero to indicate that this thread should be suspended temporarily to allow other waiting threads to execute. Specify System.Threading.Timeout.Infinite milliseconds to suspend the thread indefinitely.

Throws: : The value of timeout is negative and is not equal to System.Threading.Timeout.Infinite milliseconds, or is greater than System.Int32.MaxValue milliseconds.

This method converts timeout to milliseconds, tests the validity of the converted value, and calls System.Threading.Thread.Sleep(System.Int32)(System.Int32). The thread will not be scheduled for execution by the operating system for the amount of time specified. This method changes the state of the thread to include System.Threading.ThreadState.WaitSleepJoin.

public System.Void Start()

Causes the operating system to consider the thread ready to be scheduled for execution.

Throws: : There is not enough memory available to start the thread.

Throws: : This method was invoked on a null thread reference.

Throws: : The thread has already been started.

Calling System.Threading.Thread.Start removes the System.Threading.ThreadState.Unstarted state from the System.Threading.Thread.ThreadState of the thread. Once a thread is started, the operating system can schedule it for execution. When the thread begins executing, the System.Threading.ThreadStart delegate supplied to the constructor for the thread invokes its methods. Once the thread terminates, it cannot be restarted with another call to System.Threading.Thread.Start.

Example:

The following example demonstrates creating a thread and starting it.

using System;
using System.Threading;
public class ThreadWork {
  public static void DoWork() {
    for (int i = 0; i<3;i++) {
         Console.WriteLine ("Working thread ...");
         Thread.Sleep(100);
    }
  }
}
class ThreadTest{
  public static void Main() {
    ThreadStart myThreadDelegate = new ThreadStart(ThreadWork.DoWork);
    Thread myThread = new Thread(myThreadDelegate);
    myThread.Start();
    for (int i = 0; i<3; i++) {
        Console.WriteLine("In main.");
        Thread.Sleep(100);
    }
  }
}
   

One possible set of output is

In main.

Working thread ...

In main.

Working thread ...

In main.

Working thread ...

Note that the sequence of the output statements is not guaranteed to be identical across systems.

public static System.Object VolatileRead(System.Object& address)

Performs a volatile read from the specified address.

Parameter address: A System.Object that specifies the address in memory from which to read.

Returns: A System.Object containing the value at the specified address after any pending writes.

The value at the given address is atomically loaded with acquire semantics, meaning that the read is guaranteed to occur prior to any references to memory that occur after the execution of this method in the current thread. It is recommended that System.Threading.Thread.VolatileRead and System.Threading.Thread.VolatileWrite be used in conjunction. Calling this method affects only this single access; other accesses to the same location are required to also be made using this method or System.Threading.Thread.VolatileWrite if the volatile semantics are to be preserved. This method has exactly the same semantics as using the volatile prefix on the load IL instruction, except that atomicity is provided for all types, not just those 32 bits or smaller in size. For additional information, see Partition I of the CLI Specification.

public static System.Double VolatileRead(System.Double& address)

Performs a volatile read from the specified address.

Parameter address: A System.Double that specifies the address in memory from which to read.

Returns: A System.Double containing the value at the specified address after any pending writes.

The value at the given address is atomically loaded with acquire semantics, meaning that the read is guaranteed to occur prior to any references to memory that occur after the execution of this method in the current thread. It is recommended that System.Threading.Thread.VolatileRead and System.Threading.Thread.VolatileWrite be used in conjunction. Calling this method affects only this single access; other accesses to the same location are required to also be made using this method or System.Threading.Thread.VolatileWrite if the volatile semantics are to be preserved. This method has exactly the same semantics as using the volatile prefix on the load IL instruction, except that atomicity is provided for all types, not just those 32 bits or smaller in size. For additional information, see Partition I of the CLI Specification.

public static System.Single VolatileRead(System.Single& address)

Performs a volatile read from the specified address.

Parameter address: A System.Single that specifies the address in memory from which to read.

Returns: A System.Single containing the value at the specified address after any pending writes.

The value at the given address is atomically loaded with acquire semantics, meaning that the read is guaranteed to occur prior to any references to memory that occur after the execution of this method in the current thread. It is recommended that System.Threading.Thread.VolatileRead and System.Threading.Thread.VolatileWrite be used in conjunction. Calling this method affects only this single access; other accesses to the same location are required to also be made using this method or System.Threading.Thread.VolatileWrite if the volatile semantics are to be preserved. This method has exactly the same semantics as using the volatile prefix on the load IL instruction, except that atomicity is provided for all types, not just those 32 bits or smaller in size. For additional information, see Partition I of the CLI Specification.

public static System.UInt64 VolatileRead(System.UInt64& address)

Performs a volatile read from the specified address.

Parameter address: A System.UInt64 that specifies the address in memory from which to read.

Returns: A System.UInt64 containing the value at the specified address after any pending writes.

The value at the given address is atomically loaded with acquire semantics, meaning that the read is guaranteed to occur prior to any references to memory that occur after the execution of this method in the current thread. It is recommended that System.Threading.Thread.VolatileRead and System.Threading.Thread.VolatileWrite be used in conjunction. Calling this method affects only this single access; other accesses to the same location are required to also be made using this method or System.Threading.Thread.VolatileWrite if the volatile semantics are to be preserved. This method has exactly the same semantics as using the volatile prefix on the load IL instruction, except that atomicity is provided for all types, not just those 32 bits or smaller in size. For additional information, see Partition I of the CLI Specification.

public static System.UIntPtr VolatileRead(System.UIntPtr& address)

Performs a volatile read from the specified address.

Parameter address: A System.UIntPtr that specifies the address in memory from which to read.

Returns: A System.UIntPtr containing the value at the specified address after any pending writes.

The value at the given address is atomically loaded with acquire semantics, meaning that the read is guaranteed to occur prior to any references to memory that occur after the execution of this method in the current thread. It is recommended that System.Threading.Thread.VolatileRead and System.Threading.Thread.VolatileWrite be used in conjunction. Calling this method affects only this single access; other accesses to the same location are required to also be made using this method or System.Threading.Thread.VolatileWrite if the volatile semantics are to be preserved. This method has exactly the same semantics as using the volatile prefix on the load IL instruction, except that atomicity is provided for all types, not just those 32 bits or smaller in size. For additional information, see Partition I of the CLI Specification.

public static System.IntPtr VolatileRead(System.IntPtr& address)

Performs a volatile read from the specified address.

Parameter address: A System.IntPtr that specifies the address in memory from which to read.

Returns: A System.IntPtr containing the value at the specified address after any pending writes.

The value at the given address is atomically loaded with acquire semantics, meaning that the read is guaranteed to occur prior to any references to memory that occur after the execution of this method in the current thread. It is recommended that System.Threading.Thread.VolatileRead and System.Threading.Thread.VolatileWrite be used in conjunction. Calling this method affects only this single access; other accesses to the same location are required to also be made using this method or System.Threading.Thread.VolatileWrite if the volatile semantics are to be preserved. This method has exactly the same semantics as using the volatile prefix on the load IL instruction, except that atomicity is provided for all types, not just those 32 bits or smaller in size. For additional information, see Partition I of the CLI Specification.

public static System.UInt32 VolatileRead(System.UInt32& address)

Performs a volatile read from the specified address.

Parameter address: A System.UInt32 that specifies the address in memory from which to read.

Returns: A System.UInt32 containing the value at the specified address after any pending writes.

The value at the given address is atomically loaded with acquire semantics, meaning that the read is guaranteed to occur prior to any references to memory that occur after the execution of this method in the current thread. It is recommended that System.Threading.Thread.VolatileRead and System.Threading.Thread.VolatileWrite be used in conjunction. Calling this method affects only this single access; other accesses to the same location are required to also be made using this method or System.Threading.Thread.VolatileWrite if the volatile semantics are to be preserved. This method has exactly the same semantics as using the volatile prefix on the load IL instruction, except that atomicity is provided for all types, not just those 32 bits or smaller in size. For additional information, see Partition I of the CLI Specification.

public static System.UInt16 VolatileRead(System.UInt16& address)

Performs a volatile read from the specified address.

Parameter address: A System.UInt16 that specifies the address in memory from which to read.

Returns: A System.UInt16 containing the value at the specified address after any pending writes.

The value at the given address is atomically loaded with acquire semantics, meaning that the read is guaranteed to occur prior to any references to memory that occur after the execution of this method in the current thread. It is recommended that System.Threading.Thread.VolatileRead and System.Threading.Thread.VolatileWrite be used in conjunction. Calling this method affects only this single access; other accesses to the same location are required to also be made using this method or System.Threading.Thread.VolatileWrite if the volatile semantics are to be preserved. This method has exactly the same semantics as using the volatile prefix on the load IL instruction, except that atomicity is provided for all types, not just those 32 bits or smaller in size. For additional information, see Partition I of the CLI Specification.

public static System.SByte VolatileRead(System.SByte& address)

Performs a volatile read from the specified address.

Parameter address: A System.SByte that specifies the address in memory from which to read.

Returns: A System.SByte containing the value at the specified address after any pending writes.

The value at the given address is atomically loaded with acquire semantics, meaning that the read is guaranteed to occur prior to any references to memory that occur after the execution of this method in the current thread. It is recommended that System.Threading.Thread.VolatileRead and System.Threading.Thread.VolatileWrite be used in conjunction. Calling this method affects only this single access; other accesses to the same location are required to also be made using this method or System.Threading.Thread.VolatileWrite if the volatile semantics are to be preserved. This method has exactly the same semantics as using the volatile prefix on the load IL instruction, except that atomicity is provided for all types, not just those 32 bits or smaller in size. For additional information, see Partition I of the CLI Specification.

public static System.Int64 VolatileRead(System.Int64& address)

Performs a volatile read from the specified address.

Parameter address: A System.Int64 that specifies the address in memory from which to read.

Returns: A System.Int64 containing the value at the specified address after any pending writes.

The value at the given address is atomically loaded with acquire semantics, meaning that the read is guaranteed to occur prior to any references to memory that occur after the execution of this method in the current thread. It is recommended that System.Threading.Thread.VolatileRead and System.Threading.Thread.VolatileWrite be used in conjunction. Calling this method affects only this single access; other accesses to the same location are required to also be made using this method or System.Threading.Thread.VolatileWrite if the volatile semantics are to be preserved. This method has exactly the same semantics as using the volatile prefix on the load IL instruction, except that atomicity is provided for all types, not just those 32 bits or smaller in size. For additional information, see Partition I of the CLI Specification.

public static System.Int32 VolatileRead(System.Int32& address)

Performs a volatile read from the specified address.

Parameter address: A System.Int32 that specifies the address in memory from which to read.

Returns: A System.Int32 containing the value at the specified address after any pending writes.

The value at the given address is atomically loaded with acquire semantics, meaning that the read is guaranteed to occur prior to any references to memory that occur after the execution of this method in the current thread. It is recommended that System.Threading.Thread.VolatileRead and System.Threading.Thread.VolatileWrite be used in conjunction. Calling this method affects only this single access; other accesses to the same location are required to also be made using this method or System.Threading.Thread.VolatileWrite if the volatile semantics are to be preserved. This method has exactly the same semantics as using the volatile prefix on the load IL instruction, except that atomicity is provided for all types, not just those 32 bits or smaller in size. For additional information, see Partition I of the CLI Specification.

public static System.Int16 VolatileRead(System.Int16& address)

Performs a volatile read from the specified address.

Parameter address: A System.Int16 that specifies the address in memory from which to read.

Returns: A System.Int16 containing the value at the specified address after any pending writes.

The value at the given address is atomically loaded with acquire semantics, meaning that the read is guaranteed to occur prior to any references to memory that occur after the execution of this method in the current thread. It is recommended that System.Threading.Thread.VolatileRead and System.Threading.Thread.VolatileWrite be used in conjunction. Calling this method affects only this single access; other accesses to the same location are required to also be made using this method or System.Threading.Thread.VolatileWrite if the volatile semantics are to be preserved. This method has exactly the same semantics as using the volatile prefix on the load IL instruction, except that atomicity is provided for all types, not just those 32 bits or smaller in size. For additional information, see Partition I of the CLI Specification.

public static System.Byte VolatileRead(System.Byte& address)

Performs a volatile read from the specified address.

Parameter address: A System.Byte that specifies the address in memory from which to read.

Returns: A System.Byte containing the value at the specified address after any pending writes.

The value at the given address is atomically loaded with acquire semantics, meaning that the read is guaranteed to occur prior to any references to memory that occur after the execution of this method in the current thread. It is recommended that System.Threading.Thread.VolatileRead and System.Threading.Thread.VolatileWrite be used in conjunction. Calling this method affects only this single access; other accesses to the same location are required to also be made using this method or System.Threading.Thread.VolatileWrite if the volatile semantics are to be preserved. This method has exactly the same semantics as using the volatile prefix on the load IL instruction, except that atomicity is provided for all types, not just those 32 bits or smaller in size. For additional information, see Partition I of the CLI Specification.

public static System.Void VolatileWrite(System.UInt32& address, System.UInt32 value)

Performs a volatile write to the specified address.

Parameter address: A System.UInt32 that specifies the address in memory at which to write.

Parameter value: A System.UInt32 that specifies the value to write.

The value is written atomically to the specified address with release semantics, meaning that the write is guaranteed to happen after any references to memory that occur prior to the execution. It is recommended that System.Threading.Thread.VolatileRead and System.Threading.Thread.VolatileWrite be used in conjunction. Calling this method affects only this single access; other accesses to the same location are required to also be made using this method or System.Threading.Thread.VolatileRead if the volatile semantics are to be preserved. This method has exactly the same semantics as using the volatile prefix on the store IL instruction, except that atomicity is provided for all types, not just those 32 bits or smaller in size. For additional information, see Partition I of the CLI Specification.

public static System.Void VolatileWrite(UInt64& address, System.UInt64 value)

Performs a volatile write to the specified address.

Parameter address: A System.UInt64 that specifies the address in memory at which to write.

Parameter value: A System.UInt64 that specifies the value to write.

The value is written atomically to the specified address with release semantics, meaning that the write is guaranteed to happen after any references to memory that occur prior to the execution. It is recommended that System.Threading.Thread.VolatileRead and System.Threading.Thread.VolatileWrite be used in conjunction. Calling this method affects only this single access; other accesses to the same location are required to also be made using this method or System.Threading.Thread.VolatileRead if the volatile semantics are to be preserved. This method has exactly the same semantics as using the volatile prefix on the store IL instruction, except that atomicity is provided for all types, not just those 32 bits or smaller in size. For additional information, see Partition I of the CLI Specification.

public static System.Void VolatileWrite(System.UIntPtr& address, System.UIntPtr value)

Performs a volatile write to the specified address.

Parameter address: A System.UIntPtr that specifies the address in memory at which to write.

Parameter value: A System.UIntPtr that specifies the value to write.

The value is written atomically to the specified address with release semantics, meaning that the write is guaranteed to happen after any references to memory that occur prior to the execution. It is recommended that System.Threading.Thread.VolatileRead and System.Threading.Thread.VolatileWrite be used in conjunction. Calling this method affects only this single access; other accesses to the same location are required to also be made using this method or System.Threading.Thread.VolatileRead if the volatile semantics are to be preserved. This method has exactly the same semantics as using the volatile prefix on the store IL instruction, except that atomicity is provided for all types, not just those 32 bits or smaller in size. For additional information, see Partition I of the CLI Specification.

public static System.Void VolatileWrite(System.IntPtr& address, System.IntPtr value)

Performs a volatile write to the specified address.

Parameter address: A System.IntPtr that specifies the address in memory at which to write.

Parameter value: A System.IntPtr that specifies the value to write.

The value is written atomically to the specified address with release semantics, meaning that the write is guaranteed to happen after any references to memory that occur prior to the execution. It is recommended that System.Threading.Thread.VolatileRead and System.Threading.Thread.VolatileWrite be used in conjunction. Calling this method affects only this single access; other accesses to the same location are required to also be made using this method or System.Threading.Thread.VolatileRead if the volatile semantics are to be preserved. This method has exactly the same semantics as using the volatile prefix on the store IL instruction, except that atomicity is provided for all types, not just those 32 bits or smaller in size. For additional information, see Partition I of the CLI Specification.

public static System.Void VolatileWrite(System.Single& address, System.Single value)

Performs a volatile write to the specified address.

Parameter address: A System.Single that specifies the address in memory at which to write.

Parameter value: A System.Single that specifies the value to write.

The value is written atomically to the specified address with release semantics, meaning that the write is guaranteed to happen after any references to memory that occur prior to the execution. It is recommended that System.Threading.Thread.VolatileRead and System.Threading.Thread.VolatileWrite be used in conjunction. Calling this method affects only this single access; other accesses to the same location are required to also be made using this method or System.Threading.Thread.VolatileRead if the volatile semantics are to be preserved. This method has exactly the same semantics as using the volatile prefix on the store IL instruction, except that atomicity is provided for all types, not just those 32 bits or smaller in size. For additional information, see Partition I of the CLI Specification.

public static System.Void VolatileWrite(System.Double& address, System.Double value)

Performs a volatile write to the specified address.

Parameter address: A System.Double that specifies the address in memory at which to write.

Parameter value: A System.Double that specifies the value to write.

The value is written atomically to the specified address with release semantics, meaning that the write is guaranteed to happen after any references to memory that occur prior to the execution. It is recommended that System.Threading.Thread.VolatileRead and System.Threading.Thread.VolatileWrite be used in conjunction. Calling this method affects only this single access; other accesses to the same location are required to also be made using this method or System.Threading.Thread.VolatileRead if the volatile semantics are to be preserved. This method has exactly the same semantics as using the volatile prefix on the store IL instruction, except that atomicity is provided for all types, not just those 32 bits or smaller in size. For additional information, see Partition I of the CLI Specification.

public static System.Void VolatileWrite(System.Object& address, System.Object value)

Performs a volatile write to the specified address.

Parameter address: A System.Object that specifies the address in memory at which to write.

Parameter value: A System.Object that specifies the value to write.

The value is written atomically to the specified address with release semantics, meaning that the write is guaranteed to happen after any references to memory that occur prior to the execution. It is recommended that System.Threading.Thread.VolatileRead and System.Threading.Thread.VolatileWrite be used in conjunction. Calling this method affects only this single access; other accesses to the same location are required to also be made using this method or System.Threading.Thread.VolatileRead if the volatile semantics are to be preserved. This method has exactly the same semantics as using the volatile prefix on the store IL instruction, except that atomicity is provided for all types, not just those 32 bits or smaller in size. For additional information, see Partition I of the CLI Specification.

public static System.Void VolatileWrite(System.UInt16& address, System.UInt16 value)

Performs a volatile write to the specified address.

Parameter address: A System.UInt16 that specifies the address in memory at which to write.

Parameter value: A System.UInt16 that specifies the value to write.

The value is written atomically to the specified address with release semantics, meaning that the write is guaranteed to happen after any references to memory that occur prior to the execution. It is recommended that System.Threading.Thread.VolatileRead and System.Threading.Thread.VolatileWrite be used in conjunction. Calling this method affects only this single access; other accesses to the same location are required to also be made using this method or System.Threading.Thread.VolatileRead if the volatile semantics are to be preserved. This method has exactly the same semantics as using the volatile prefix on the store IL instruction, except that atomicity is provided for all types, not just those 32 bits or smaller in size. For additional information, see Partition I of the CLI Specification.

public static System.Void VolatileWrite(System.SByte& address, System.SByte value)

Performs a volatile write to the specified address.

Parameter address: A System.SByte that specifies the address in memory at which to write.

Parameter value: A System.SByte that specifies the value to write.

The value is written atomically to the specified address with release semantics, meaning that the write is guaranteed to happen after any references to memory that occur prior to the execution. It is recommended that System.Threading.Thread.VolatileRead and System.Threading.Thread.VolatileWrite be used in conjunction. Calling this method affects only this single access; other accesses to the same location are required to also be made using this method or System.Threading.Thread.VolatileRead if the volatile semantics are to be preserved. This method has exactly the same semantics as using the volatile prefix on the store IL instruction, except that atomicity is provided for all types, not just those 32 bits or smaller in size. For additional information, see Partition I of the CLI Specification.

public static System.Void VolatileWrite(System.Int64& address, System.Int64 value)

Performs a volatile write to the specified address.

Parameter address: A System.Int64 that specifies the address in memory at which to write.

Parameter value: A System.Int64 that specifies the value to write.

The value is written atomically to the specified address with release semantics, meaning that the write is guaranteed to happen after any references to memory that occur prior to the execution. It is recommended that System.Threading.Thread.VolatileRead and System.Threading.Thread.VolatileWrite be used in conjunction. Calling this method affects only this single access; other accesses to the same location are required to also be made using this method or System.Threading.Thread.VolatileRead if the volatile semantics are to be preserved. This method has exactly the same semantics as using the volatile prefix on the store IL instruction, except that atomicity is provided for all types, not just those 32 bits or smaller in size. For additional information, see Partition I of the CLI Specification.

public static System.Void VolatileWrite(System.Int32& address, System.Int32 value)

Performs a volatile write to the specified address.

Parameter address: A System.Int32 that specifies the address in memory at which to write.

Parameter value: A System.Int32 that specifies the value to write.

The value is written atomically to the specified address with release semantics, meaning that the write is guaranteed to happen after any references to memory that occur prior to the execution. It is recommended that System.Threading.Thread.VolatileRead and System.Threading.Thread.VolatileWrite be used in conjunction. Calling this method affects only this single access; other accesses to the same location are required to also be made using this method or System.Threading.Thread.VolatileRead if the volatile semantics are to be preserved. This method has exactly the same semantics as using the volatile prefix on the store IL instruction, except that atomicity is provided for all types, not just those 32 bits or smaller in size. For additional information, see Partition I of the CLI Specification.

public static System.Void VolatileWrite(System.Int16& address, System.Int16 value)

Performs a volatile write to the specified address.

Parameter address: A System.Int16 that specifies the address in memory at which to write.

Parameter value: A System.Int16 that specifies the value to write.

The value is written atomically to the specified address with release semantics, meaning that the write is guaranteed to happen after any references to memory that occur prior to the execution. It is recommended that System.Threading.Thread.VolatileRead and System.Threading.Thread.VolatileWrite be used in conjunction. Calling this method affects only this single access; other accesses to the same location are required to also be made using this method or System.Threading.Thread.VolatileRead if the volatile semantics are to be preserved. This method has exactly the same semantics as using the volatile prefix on the store IL instruction, except that atomicity is provided for all types, not just those 32 bits or smaller in size. For additional information, see Partition I of the CLI Specification.

public static System.Void VolatileWrite(System.Byte& address, System.Byte value)

Performs a volatile write to the specified address.

Parameter address: A System.Byte that specifies the address in memory at which to write.

Parameter value: A System.Byte that specifies the value to write.

The value is written atomically to the specified address with release semantics, meaning that the write is guaranteed to happen after any references to memory that occur prior to the execution. It is recommended that System.Threading.Thread.VolatileRead and System.Threading.Thread.VolatileWrite be used in conjunction. Calling this method affects only this single access; other accesses to the same location are required to also be made using this method or System.Threading.Thread.VolatileRead if the volatile semantics are to be preserved. This method has exactly the same semantics as using the volatile prefix on the store IL instruction, except that atomicity is provided for all types, not just those 32 bits or smaller in size. For additional information, see Partition I of the CLI Specification.

Functions inherited from System.Object:

public virtual System.Boolean Equals(System.Object obj)

Determines whether the specified System.Object is equal to the current instance.

Parameter obj: The System.Object to compare with the current instance.

Returns: true if obj is equal to the current instance; otherwise, false.

The statements listed below are required to be true for all implementations of the System.Object.Equals(System.Object) method. In the list, x, y, and z represent non-null object references. See System.Object.GetHashCode for additional required behaviors pertaining to the System.Object.Equals(System.Object) method. Implementations of System.Object.Equals(System.Object) should not throw exceptions. The System.Object.Equals(System.Object) method tests for referential equality , which means that System.Object.Equals(System.Object) returns true if the specified instance of Object and the current instance are the same instance; otherwise, it returns false . An implementation of the System.Object.Equals(System.Object) method is shown in the following C# code: public virtual bool Equals(Object obj) { return this == obj; } For some kinds of objects, it is desirable to have System.Object.Equals(System.Object) test for value equality instead of referential equality. Such implementations of Equals return true if the two objects have the same "value", even if they are not the same instance. The definition of what constitutes an object's "value" is up to the implementer of the type, but it is typically some or all of the data stored in the instance variables of the object. For example, the value of a System.String is based on the characters of the string; the Equals method of the System.String class returns true for any two string instances that contain exactly the same characters in the same order. When the Equals method of a base class provides value equality, an override of Equals in a class derived from that base class should invoke the inherited implementation of Equals . It is recommended (but not required) that types overriding System.Object.Equals(System.Object) also override System.Object.GetHashCode. Hashtables cannot be relied on to work correctly if this recommendation is not followed. If your programming language supports operator overloading, and if you choose to overload the equality operator for a given type, that type should override the Equals method. Such implementations of the Equals method should return the same results as the equality operator. Following this guideline will help ensure that class library code using Equals (such as System.Collections.ArrayList and System.Collections.Hashtable ) behaves in a manner that is consistent with the way the equality operator is used by application code. If you are implementing a value type, you should follow these guidelines: For reference types, the guidelines are as follows: If you implement System.IComparable on a given type, you should override Equals on that type. The System.Object.Equals(System.Object) method is called by methods in collections classes that perform search operations, including the System.Array.IndexOf(System.Array,System.Object) method and the System.Collections.ArrayList.Contains(System.Object) method.

Example:

Example 1:

The following example contains two calls to the default implementation of System.Object.Equals(System.Object) .

using System;
class MyClass {
   static void Main() {
      Object obj1 = new Object();
      Object obj2 = new Object();
      Console.WriteLine(obj1.Equals(obj2));
      obj1 = obj2; 
      Console.WriteLine(obj1.Equals(obj2)); 
   }
}

The output is

False

True

Example 2:

The following example shows a Point class that overrides the System.Object.Equals(System.Object) method to provide value equality and a class Point3D, which is derived from Point . Because Point's override of System.Object.Equals(System.Object) is the first in the inheritance chain to introduce value equality, the Equals method of the base class (which is inherited from System.Object and checks for referential equality) is not invoked. However, Point3D.Equals invokes Point.Equals because Point implements Equals in a manner that provides value equality.

using System;
public class Point: object {
 int x, y;
 public override bool Equals(Object obj) {
 //Check for null and compare run-time types.
 if (obj == null || GetType() != obj.GetType()) return false;
 Point p = (Point)obj;
 return (x == p.x) && (y == p.y);
 }
 public override int GetHashCode() {
 return x ^ y;
 }
}

class Point3D: Point {
 int z;
 public override bool Equals(Object obj) {
 return base.Equals(obj) && z == ((Point3D)obj).z;
 }
 public override int GetHashCode() {
 return base.GetHashCode() ^ z;
 }
}

The Point.Equals method checks that the obj argument is non-null and that it references an instance of the same type as this object. If either of those checks fail, the method returns false. The System.Object.Equals(System.Object) method uses System.Object.GetType to determine whether the run-time types of the two objects are identical. (Note that typeof is not used here because it returns the static type.) If instead the method had used a check of the form

<doc:param name="obj"/>
is Point , the check would return true in cases where obj is an instance of a subclass of Point , even though obj and the current instance are not of the same runtime type. Having verified that both objects are of the same type, the method casts obj to type Point and returns the result of comparing the instance variables of the two objects.

In Point3D.Equals , the inherited Equals method is invoked before anything else is done; the inherited Equals method checks to see that obj is non-null, that obj is an instance of the same class as this object, and that the inherited instance variables match. Only when the inherited Equals returns true does the method compare the instance variables introduced in the subclass. Specifically, the cast to Point3D is not executed unless obj has been determined to be of type Point3D or a subclass of Point3D .

Example 3:

In the previous example, operator == (the equality operator) is used to compare the individual instance variables. In some cases, it is appropriate to use the System.Object.Equals(System.Object) method to compare instance variables in an Equals implementation, as shown in the following example:

using System;
class Rectangle {
 Point a, b;
 public override bool Equals(Object obj) {
 if (obj == null || GetType() != obj.GetType()) return false;
 Rectangle r = (Rectangle)obj;
 //Use Equals to compare instance variables
 return a.Equals(r.a) && b.Equals(r.b);
 }
 public override int GetHashCode() {
 return a.GetHashCode() ^ b.GetHashCode();
 }
}

Example 4:

In some languages, such as C#, operator overloading is supported. When a type overloads operator ==, it should also override the System.Object.Equals(System.Object) method to provide the same functionality. This is typically accomplished by writing the Equals method in terms of the overloaded operator ==. For example:

using System;
public struct Complex {
 double re, im;
 public override bool Equals(Object obj) {
 return obj is Complex && this == (Complex)obj;
 }
 public override int GetHashCode() {
 return re.GetHashCode() ^ im.GetHashCode();
 }
 public static bool operator ==(Complex x, Complex y) {
 return x.re == y.re && x.im == y.im;
 }
 public static bool operator !=(Complex x, Complex y) {
 return !(x == y);
 }
}

Because Complex is a C# struct (a value type), it is known that there will be no subclasses of Complex . Therefore, the System.Object.Equals(System.Object) method need not compare the GetType() results for each object, but can instead use the is operator to check the type of the obj parameter.

public static System.Boolean Equals(System.Object objA, System.Object objB)

Determines whether two object references are equal.

Parameter objA: First object to compare.

Parameter objB: Second object to compare.

Returns: true if one or more of the following statements is true: otherwise returns false.

This static method checks for null references before it calls objA.Equals(objB ) and returns false if either objA or objB is null. If the Equals(object obj) implementation throws an exception, this method throws an exception.

Example:

The following example demonstrates the System.Object.Equals(System.Object) method.

using System;

public class MyClass {
   public static void Main() {
   string s1 = "Tom";
   string s2 = "Carol";
   Console.WriteLine("Object.Equals(\"{0}\", \"{1}\") => {2}", 
      s1, s2, Object.Equals(s1, s2));

   s1 = "Tom";
   s2 = "Tom";
   Console.WriteLine("Object.Equals(\"{0}\", \"{1}\") => {2}", 
      s1, s2, Object.Equals(s1, s2));

   s1 = null;
   s2 = "Tom";
   Console.WriteLine("Object.Equals(null, \"{1}\") => {2}",
       s1, s2, Object.Equals(s1, s2));

   s1 = "Carol";
   s2 = null;
   Console.WriteLine("Object.Equals(\"{0}\", null) => {2}", 
       s1, s2, Object.Equals(s1, s2));

   s1 = null;
   s2 = null;
   Console.WriteLine("Object.Equals(null, null) => {2}", 
       s1, s2, Object.Equals(s1, s2));
   }
}
   

The output is

Object.Equals("Tom", "Carol") => False

Object.Equals("Tom", "Tom") => True

Object.Equals(null, "Tom") => False

Object.Equals("Carol", null) => False

Object.Equals(null, null) => True

public System.Void Finalize()

Allows a System.Object to perform cleanup operations before the memory allocated for the System.Object is automatically reclaimed.

During execution, System.Object.Finalize is automatically called after an object becomes inaccessible, unless the object has been exempted from finalization by a call to System.GC.SuppressFinalize(System.Object). During shutdown of an application domain, System.Object.Finalize is automatically called on objects that are not exempt from finalization, even those that are still accessible. System.Object.Finalize is automatically called only once on a given instance, unless the object is re-registered using a mechanism such as System.GC.ReRegisterForFinalize(System.Object) and System.GC.SuppressFinalize(System.Object) has not been subsequently called. Conforming implementations of the CLI are required to make every effort to ensure that for every object that has not been exempted from finalization, the System.Object.Finalize method is called after the object becomes inaccessible. However, there may be some circumstances under which Finalize is not called. Conforming CLI implementations are required to explicitly specify the conditions under which Finalize is not guaranteed to be called. For example, Finalize might not be guaranteed to be called in the event of equipment failure, power failure, or other catastrophic system failures. In addition to System.GC.ReRegisterForFinalize(System.Object) and System.GC.SuppressFinalize(System.Object), conforming implementations of the CLI are allowed to provide other mechanisms that affect the behavior of System.Object.Finalize . Any mechanisms provided are required to be specified by the CLI implementation. The order in which the Finalize methods of two objects are run is unspecified, even if one object refers to the other. The thread on which Finalize is run is unspecified. Every implementation of System.Object.Finalize in a derived type is required to call its base type's implementation of Finalize . This is the only case in which application code calls System.Object.Finalize . The System.Object.Finalize implementation does nothing. A type should implement Finalize when it uses unmanaged resources such as file handles or database connections that must be released when the managed object that uses them is reclaimed. Because Finalize methods may be invoked in any order (including from multiple threads), synchronization may be necessary if the Finalize method may interact with other objects, whether accessible or not. Furthermore, since the order in which Finalize is called is unspecified, implementers of Finalize (or of destructors implemented through overriding Finalize) must take care to correctly handle references to other objects, as their Finalize method may already have been invoked. In general, referenced objects should not be considered valid during finalization. See the System.IDisposable interface for an alternate means of disposing of resources. For C# developers: Destructors are the C# mechanism for performing cleanup operations. Destructors provide appropriate safeguards, such as automatically calling the base type's destructor. In C# code, System.Object.Finalize cannot be called or overridden.

public virtual System.Int32 GetHashCode()

Generates a hash code for the current instance.

Returns: A System.Int32 containing the hash code for the current instance.

System.Object.GetHashCode serves as a hash function for a specific type. A hash function is used to quickly generate a number (a hash code) corresponding to the value of an object. Hash functions are used with hashtables. A good hash function algorithm rarely generates hash codes that collide. For more information about hash functions, see The Art of Computer Programming , Vol. 3, by Donald E. Knuth. All implementations of System.Object.GetHashCode are required to ensure that for any two object references x and y, if x.Equals(y) == true, then x.GetHashCode() == y.GetHashCode(). Hash codes generated by System.Object.GetHashCode need not be unique. Implementations of System.Object.GetHashCode are not permitted to throw exceptions. The System.Object.GetHashCode implementation attempts to produce a unique hash code for every object, but the hash codes generated by this method are not guaranteed to be unique. Therefore, System.Object.GetHashCode may generate the same hash code for two different instances. It is recommended (but not required) that types overriding System.Object.GetHashCode also override System.Object.Equals(System.Object) . Hashtables cannot be relied on to work correctly if this recommendation is not followed. Use this method to obtain the hash code of an object. Hash codes should not be persisted (i.e. in a database or file) as they are allowed to change from run to run.

Example:

Example 1

In some cases, System.Object.GetHashCode is implemented to simply return an integer value. The following example illustrates an implementation of System.Int32.GetHashCode , which returns an integer value:

using System;
public struct Int32 {
 int value;
 //other methods...

 public override int GetHashCode() {
 return value;
 }
}

Example 2

Frequently, a type has multiple data members that can participate in generating the hash code. One way to generate a hash code is to combine these fields using an xor (exclusive or) operation, as shown in the following example:

using System;
public struct Point {
 int x;
 int y; 
 //other methods
 
 public override int GetHashCode() {
 return x ^ y;
 }
}

Example 3

The following example illustrates another case where the type's fields are combined using xor (exclusive or) to generate the hash code. Notice that in this example, the fields represent user-defined types, each of which implements System.Object.GetHashCode (and should implement System.Object.Equals(System.Object) as well):

using System;
public class SomeType {
 public override int GetHashCode() {
 return 0;
 }
}

public class AnotherType {
 public override int GetHashCode() {
 return 1;
 }
}

public class LastType {
 public override int GetHashCode() {
 return 2;
 }
}
public class MyClass {
 SomeType a = new SomeType();
 AnotherType b = new AnotherType();
 LastType c = new LastType();

 public override int GetHashCode () {
 return a.GetHashCode() ^ b.GetHashCode() ^ c.GetHashCode();
 }
}

Avoid implementing System.Object.GetHashCode in a manner that results in circular references. In other words, if AClass.GetHashCode calls BClass.GetHashCode, it should not be the case that BClass.GetHashCode calls AClass.GetHashCode.

Example 4

In some cases, the data member of the class in which you are implementing System.Object.GetHashCode is bigger than a System.Int32. In such cases, you could combine the high order bits of the value with the low order bits using an XOR operation, as shown in the following example:

using System;
public struct Int64 {
 long value;
 //other methods...

 public override int GetHashCode() {
 return ((int)value ^ (int)(value >> 32));
 }
}

public System.Type GetType()

Gets the type of the current instance.

Returns: The instance of System.Type that represents the run-time type (the exact type) of the current instance.

For two objects x and y that have identical run-time types, System.Object.ReferenceEquals(System.Object,System.Object)(x.GetType(),y.GetType()) returns true .

Example:

The following example demonstrates the fact that System.Object.GetType returns the run-time type of the current instance:

using System;
public class MyBaseClass: Object {
}
public class MyDerivedClass: MyBaseClass {
}
public class Test {
   public static void Main() {
   MyBaseClass myBase = new MyBaseClass();
   MyDerivedClass myDerived = new MyDerivedClass();

   object o = myDerived;
   MyBaseClass b = myDerived;

   Console.WriteLine("mybase: Type is {0}", myBase.GetType());
   Console.WriteLine("myDerived: Type is {0}", myDerived.GetType());
   Console.WriteLine("object o = myDerived: Type is {0}", o.GetType());
   Console.WriteLine("MyBaseClass b = myDerived: Type is {0}", b.GetType());
   }
}

The output is

mybase: Type is MyBaseClass

myDerived: Type is MyDerivedClass

object o = myDerived: Type is MyDerivedClass

MyBaseClass b = myDerived: Type is MyDerivedClass

protected System.Object MemberwiseClone()

Creates a shallow copy of the current instance.

Returns: A shallow copy of the current instance. The run-time type (the exact type) of the returned object is the same as the run-time type of the object that was copied.

System.Object.MemberwiseClone creates a new instance of the same type as the current instance and then copies each of the object's non-static fields in a manner that depends on whether the field is a value type or a reference type. If the field is a value type, a bit-by-bit copy of all the field's bits is performed. If the field is a reference type, only the reference is copied. The algorithm for performing a shallow copy is as follows (in pseudo-code): for each instance field f in this instance if (f is a value type) bitwise copy the field if (f is a reference type) copy the reference end for loop This mechanism is referred to as a shallow copy because it copies rather than clones the non-static fields. Because System.Object.MemberwiseClone implements the above algorithm, for any object, a, the following statements are required to be true: System.Object.MemberwiseClone does not call any of the type's constructors. If System.Object.Equals(System.Object) has been overridden, a.MemberwiseClone().Equals(a) might return false . For an alternate copying mechanism, see System.ICloneable . System.Object.MemberwiseClone is protected (rather than public) to ensure that from verifiable code it is only possible to clone objects of the same class as the one performing the operation (or one of its subclasses). Although cloning an object does not directly open security holes, it does allow an object to be created without running any of its constructors. Since these constructors may establish important invariants, objects created by cloning may not have these invariants established, and this may lead to incorrect program behavior. For example, a constructor might add the new object to a linked list of all objects of this class, and cloning the object would not add the new object to that list -- thus operations that relied on the list to locate all instances would fail to notice the cloned object. By making the method protected, only objects of the same class (or a subclass) can produce a clone and implementers of those classes are (presumably) aware of the appropriate invariants and can arrange for them to be true without necessarily calling a constructor.

Example:

The following example shows a class called MyClass as well as a representation of the instance of MyClass returned by System.Object.MemberwiseClone .

using System;
class MyBaseClass {
   public static string CompanyName = "My Company";
   public int age;
   public string name;
}

class MyDerivedClass: MyBaseClass {

   static void Main() {
   
   //Create an instance of MyDerivedClass
   //and assign values to its fields.
   MyDerivedClass m1 = new MyDerivedClass();
   m1.age = 42;
   m1.name = "Sam";

   //Do a shallow copy of m1
   //and assign it to m2.
   MyDerivedClass m2 = (MyDerivedClass) m1.MemberwiseClone();
   }
}

A graphical representation of m1 and m2 might look like this


+---------------+

|     42        |                           m1 

+---------------+

|     +---------|-----------------> "Sam" 

+---------------+                    /|\ 

                                      | 

+---------------+                     | 

|     42        |                     |      m2 

+---------------+                     | 

|      +--------|---------------------| 

+---------------+

public static System.Boolean ReferenceEquals(System.Object objA, System.Object objB)

Determines whether two object references are identical.

Parameter objA: First object to compare.

Parameter objB: Second object to compare.

Returns: True if a and b refer to the same object or are both null references; otherwise, false.

This static method provides a way to compare two objects for reference equality. It does not call any user-defined code, including overrides of System.Object.Equals(System.Object) .

Example:

using System;
class MyClass {
   static void Main() {
   object o = null;
   object p = null;
   object q = new Object();
   Console.WriteLine(Object.ReferenceEquals(o, p));
   p = q;
   Console.WriteLine(Object.ReferenceEquals(p, q));
   Console.WriteLine(Object.ReferenceEquals(o, p));
   }
}
   

The output is

True

True

False

public virtual System.String ToString()

Creates and returns a System.String representation of the current instance.

Returns: A System.String representation of the current instance.

System.Object.ToString returns a string whose content is intended to be understood by humans. Where the object contains culture-sensitive data, the string representation returned by System.Object.ToString takes into account the current system culture. For example, for an instance of the System.Double class whose value is zero, the implementation of System.Double.ToString might return "0.00" or "0,00" depending on the current UI culture. Although there are no exact requirements for the format of the returned string, it should as much as possible reflect the value of the object as perceived by the user. System.Object.ToString is equivalent to calling System.Object.GetType to obtain the System.Type object for the current instance and then returning the result of calling the System.Object.ToString implementation for that type. The value returned includes the full name of the type. It is recommended, but not required, that System.Object.ToString be overridden in a derived class to return values that are meaningful for that type. For example, the base data types, such as System.Int32, implement System.Object.ToString so that it returns the string form of the value the object represents. Subclasses that require more control over the formatting of strings than System.Object.ToString provides should implement System.IFormattable, whose System.Object.ToString method uses the culture of the current thread.

Example:

The following example outputs the textual description of the value of an object of type System.Object to the console.

using System;

class MyClass {
   static void Main() {
      object o = new object();
      Console.WriteLine (o.ToString());
   }
}
      

The output is

System.Object