Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/.net/25.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 与VBNET中的(IntPtr)1等效?_C#_.net_Vb.net_Intptr_Code Translation - Fatal编程技术网

C# 与VBNET中的(IntPtr)1等效?

C# 与VBNET中的(IntPtr)1等效?,c#,.net,vb.net,intptr,code-translation,C#,.net,Vb.net,Intptr,Code Translation,我从@Hans Passant代码中提取了一段代码: 这是C代码: 哪一个将被翻译成vb.net 这将不起作用(无法编译): 试试这个: SendMessage(hText, WM_SETFONT, mFont.ToHfont(), New IntPtr(1)) 编译错误是什么?无法将整数强制转换为系统。IntPtr@DouglasBarbin是的,这是编译错误,谢谢你这么说。DirectCast不是C#cast运算符的通用转换。类型和要强制转换的项之间的关系必须是继承关系或实现关系。 Sen

我从@Hans Passant代码中提取了一段代码:

这是C代码:

哪一个将被翻译成vb.net

这将不起作用(无法编译):

试试这个:

SendMessage(hText, WM_SETFONT, mFont.ToHfont(), New IntPtr(1))

编译错误是什么?无法将整数强制转换为系统。IntPtr@DouglasBarbin是的,这是编译错误,谢谢你这么说。DirectCast不是C#cast运算符的通用转换。类型和要强制转换的项之间的关系必须是继承关系或实现关系。
SendMessage(hText, WM_SETFONT, mFont.ToHfont(), DirectCast(1, IntPtr))
SendMessage(hText, WM_SETFONT, mFont.ToHfont(), New IntPtr(1))