【发布时间】:2012-12-23 05:07:44
【问题描述】:
我遇到了一个C#源代码的sn-p如下
int* ptr = ...;
int w = ...;
int* ptr3 = ptr + (IntPtr)w;
CS0019: Operator '+' cannot be applied to operands of type 'int*' and 'System.IntPtr'
我猜这段代码试图将 ptr 地址向前移动 w,这取决于操作系统。这是正确的,我怎样才能编译这段代码?
【问题讨论】:
-
旁注:如果你不知道代码应该做什么,也许你不应该写它......你真的需要使用不安全的代码和指针吗?
标签: c# .net compiler-errors intptr