首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > .NET > C# >

C# 中byte* 怎么进行 + 运算

2013-02-24 
C# 中byte* 如何进行 + 运算fixed (byte* numRef this._castedRefStream.GetBuffer()){byte* pointer

C# 中byte* 如何进行 + 运算
fixed (byte* numRef = this._castedRefStream.GetBuffer())
            {
                byte* pointer = numRef + ((byte*)position);
                local.CastStructure(pointer);
            }

红色代码行出错,
错误113运算符“+”无法应用于“byte*”和“byte*”类型的操作数
c# byte*
[解决办法]
改为:

byte* pointer = numRef + position;

[解决办法]
偏移量只能是整形,或者:

byte* pointer = numRef + (int)position;
[解决办法]
指针不能和指针相加,指针可以和整形相加

byte* pointer = numRef + position;

不过这种代码还是不要用C#写,换C++更好

热点排行