0

Ok while sizeof(Myenum) and sizeof(int) works, I would like to use sizeof(object), but I don't want the size of the object, but the size of pointer... only for portability reason, I need to know if is a 64 bit pointer or 32 bit pointer, I can avoid using sizeof if is ok with conditional compilation, but I don't know if there are constants to check if we are on a 32 bit system instead of 64 bit

Thanks for suggestions

Francesco Belladonna
  • 11,361
  • 12
  • 77
  • 147
  • possible duplicate of [Identifying the CPU architecture type using C#](http://stackoverflow.com/questions/767613/identifying-the-cpu-architecture-type-using-c) – Frédéric Hamidi Dec 11 '10 at 11:13
  • possible duplicate of [How to detect Windows 64 bit platform with .net?](http://stackoverflow.com/questions/336633/how-to-detect-windows-64-bit-platform-with-net) – jgauffin Dec 11 '10 at 11:55
  • @Frédéric Hamidi: Mh the problem is, while the context is different (I want size of something), it involves cpu detection, so I think that if someone will search for sizeof(object) it's better if he finds this question, so he will not open a new one. – Francesco Belladonna Dec 11 '10 at 12:26

2 Answers2

5

Use IntPtr.Size.

Reference : Simple way to check if you're on a 64-bit machine

decyclone
  • 30,394
  • 6
  • 63
  • 80
0

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 is a pointer, found it at IntPtr Structure.

Aykut Çevik
  • 2,060
  • 3
  • 20
  • 27