// ==++== // // Copyright (c) Microsoft Corporation. All rights reserved. // // ==--== //============================================================ // // Class: IntPtr // // Purpose: Platform neutral integer // //=========================================================== namespace System { using System; using System.Globalization; using System.Runtime.CompilerServices; //| [NoCCtor] public struct IntPtr { unsafe private void* m_value; // The compiler treats void* closest to uint hence explicit casts are required to preserve int behavior //| [Intrinsic] public static readonly IntPtr Zero; //| [Intrinsic] public static readonly int Size; //| [Intrinsic] public extern IntPtr(int value); //| [Intrinsic] public extern IntPtr(long value); //| [CLSCompliant(false)] [Intrinsic] public extern unsafe IntPtr(void* value); //| public unsafe override bool Equals(Object obj) { if (obj is IntPtr) { return (m_value == ((IntPtr)obj).m_value); } return false; } //| public unsafe override int GetHashCode() { return (int)m_value; } //| [Intrinsic] public extern int ToInt32(); //| [Intrinsic] public extern long ToInt64(); //| [Inline] public unsafe override String ToString() { if (sizeof(IntPtr) == 4) { return this.ToInt32().ToString(); } return this.ToInt64().ToString(); } //| [CLSCompliant(false)] [Intrinsic] public extern static unsafe explicit operator void* (IntPtr value); [CLSCompliant(false)] [Intrinsic] public extern static explicit operator UIntPtr (IntPtr value); //| [Intrinsic] public extern static explicit operator IntPtr (int value); //| [Intrinsic] public extern static explicit operator IntPtr (long value); //| [CLSCompliant(false)] [Intrinsic] public extern static unsafe explicit operator IntPtr (void* value); //| [Intrinsic] public extern static explicit operator int (IntPtr value); //| [Intrinsic] public extern static explicit operator long (IntPtr value); //| [Intrinsic] public extern static bool operator == (IntPtr value1, IntPtr value2); //| [Intrinsic] public extern static bool operator != (IntPtr value1, IntPtr value2); //| [CLSCompliant(false)] [Intrinsic] public extern unsafe void* ToPointer(); [Intrinsic] public extern static IntPtr operator - (IntPtr value1, IntPtr value2); [Intrinsic] public extern static IntPtr operator - (IntPtr value1, int value2); [Intrinsic] public extern static IntPtr operator -- (IntPtr value); [CLSCompliant(false)] [Intrinsic] public extern static unsafe sbyte * operator + (sbyte* value1, IntPtr value2); [Intrinsic] public extern static IntPtr operator + (IntPtr value1, IntPtr value2); [Intrinsic] public extern static IntPtr operator ++ (IntPtr value); [Intrinsic] public extern static bool operator < (IntPtr value1, IntPtr value2); [Intrinsic] public extern static bool operator > (IntPtr value1, IntPtr value2); [Intrinsic] public extern static bool operator <= (IntPtr value1, IntPtr value2); [Intrinsic] public extern static bool operator >= (IntPtr value1, IntPtr value2); } }