PDA

View Full Version : نوع IntPtr



حامد فراست
سه شنبه 26 شهریور 1387, 11:20 صبح
با سلام
کسی میدونه نوع IntPtr چیه چه کار میکنه ؟؟
آیاخودش اشاره گره یا برای نمایش دادن اشارگر ازش استفاده میشه؟

Amir Oveisi
سه شنبه 26 شهریور 1387, 13:46 عصر
خودش اشاره گر نیست ولی در زبان هایی که اشاره گر ندارند برای دسترسی به مقدار یک اشاره گر استفاده میشه.
توضیحات MSDN در مورد IntPtr :

The IntPtr type is designed to be an integer whose size is platform-specific. That is, an instance of this type is expected to be 32-bits on 32-bit hardware and operating systems, and 64-bits on 64-bit hardware and operating systems.

The IntPtr type can be used by languages that support pointers, and as a common means of referring to data between languages that do and do not support pointers.

IntPtr objects can also be used to hold handles. For example, instances of IntPtr are used extensively in the System.IO.FileStream class to hold file handles.

The IntPtr type is CLS-compliant, while the UIntPtr type is not. Only the IntPtr type is used in the common language runtime. The UIntPtr type is provided mostly to maintain architectural symmetry with the IntPtr type.

This type implements the ISerializable interface.

موفق باشید
jooje

حامد فراست
چهارشنبه 27 شهریور 1387, 10:07 صبح
با تشکر از جوابتون
حلا چطور میتونم مقدار یک اشاره گر رو به یک IntPtr نسبت بدم و چطور میشه بکIntPtrرابه اشاره گر نسبت بدم؟؟؟ شاید خیلی ساده باشه ولی اگه بگین ممنون میشم.

Amir Oveisi
چهارشنبه 27 شهریور 1387, 14:01 عصر
این مثال رو ببینید لطفا
http://www.codeproject.com/KB/cs/unmanaged_memory_pointers.aspx

موفق باشید
jooje