转换“(无符号长)this"从C ++到C# [英] convert "(unsigned long)this" from C++ to C#

查看:66
本文介绍了转换“(无符号长)this"从C ++到C#的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好朋友

我在非托管dll文件中具有此功能:

Hi friends

I''ve this function in a unmanaged dll file :

CLIENT_Init(DisConnectFunc, (unsigned long)this);



我必须将此标头重新定义为C#,以便在我的C#项目中使用它,

显然,"this"引用了该类:但是如何将"



I''ve to redefine this header into C# to use it in my C# project,

It''s clear that "this" refer the class: but how to convert "

(unsigned long)this

"转换为C#,我找不到任何等效项,请帮助plz

" into C#, I''cant find any equivalence, help plz

推荐答案

您尝试了this.Handle吗?


C#没有指针(除了unsafe代码).对象由垃圾回收器在内存中移动,因此C#中的this只是对对象的引用,而不是指向内存的指针.这意味着将其强制转换为整数类型将不起作用.

尼克
C# doesn''t have pointers ( except for unsafe code ). Objects are moved around in memory by the Garbage Collector, so this in C# is only a reference to an object, not a pointer to memory. This means casting it to an integer type will not work.

Nick


这篇关于转换“(无符号长)this"从C ++到C#的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆