I have this lines in C# Visual Studio 2010:
IntPtr a = new IntPtr(10);
IntPtr b = a + 10;
And it says:
Operator '+' cannot be applied to operands of type 'System.IntPtr' and 'int'.
If you are targetting .net 4 then your code will work.
For earlier versions you need to use IntPtr.ToInt64
.
IntPtr a = new IntPtr(10);
IntPtr b = new IntPtr(a.ToInt64()+10);
Use ToInt64
rather than ToInt32
so that your code works for both 32 and 64 bit.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.