无法将索引应用于“IntPtr”类型的表达式; == IntPtr ptr1 = [...] -->指针1[0]
我找到了我想要实现的代码片段。现在的问题是有一个功能没有运行。 无法将索引应用于“IntPtr”类型的表达式
fixed (byte* numRef = this.tribuf)
{
for (int i = 0; i < num; i++)
{
item = this.trihash.GetItem(ch + S.Substring(i, 3));
if (item != null)
{
this.TrigramChecked += item.Count;
foreach (int num3 in item)
{
if ((num3 != id) && (numRef[num3] < 0xff))
{
IntPtr ptr1 = (IntPtr) (numRef + num3);
/* ToDo: Error */
ptr1[0] = (IntPtr) ((byte) (ptr1[0] + 1));
}
}
}
}
}
Chris
I found a code snippet which I want to implement. Now is the problem that one function isn't running. Cannot apply indexing to an expression of type 'IntPtr'
fixed (byte* numRef = this.tribuf)
{
for (int i = 0; i < num; i++)
{
item = this.trihash.GetItem(ch + S.Substring(i, 3));
if (item != null)
{
this.TrigramChecked += item.Count;
foreach (int num3 in item)
{
if ((num3 != id) && (numRef[num3] < 0xff))
{
IntPtr ptr1 = (IntPtr) (numRef + num3);
/* ToDo: Error */
ptr1[0] = (IntPtr) ((byte) (ptr1[0] + 1));
}
}
}
}
}
regards Chris
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
正如我在评论中所说,我首先会尝试避免不安全的代码,但它看起来实际上只是尝试这样做:
或者也许更有效(仅从
numRef 读取[num3]
一次):As I said in a comment, I would try to avoid unsafe code in the first place, but it looks like it's really just trying to do:
Or perhaps more efficiently (to only read from
numRef[num3]
once):