我在 VB6 中有一些从 dll 导入函数的代码,它使用 byVal 和 byRef 关键字,我想将该代码转换为 C# 3.5。
字符串的unicode编码会有问题吗?
我是否将 vb6 中的“byRef”变量声明为 C# 代码中的“ref”变量?
它将返回值输入到由 VB6 代码作为“byVal”参数发送的字符串中,这是如何工作的,如果你想允许函数编辑字符串,你不应该发送东西“byRef”吗? 这个概念仍然适用于我的 C# 代码吗?
我尝试从 VB6 处理函数声明,参数类型只是 int、long 和 string。在有“byVal”关键字的地方,我只是将其留空,并用 C# 中的“ref”关键字替换了“byRef”关键字,代码不起作用。
VB6 代码:
Private Declare Function Foo Lib "Foo_Functions.dll" (ByVal a as String, ByVal b
as Long, ByVal c as String, ByVal d as String, ByVal e as String, ByVal f
as String, ByVal g as Long, ByVal h as String , ByVal i as String, ByRef j
as Long, ByRef k as Long) As
Integer
我的 C# 3.5 翻译:
[Dllimkport("foo_functions.dll")] public static extern int foo(String a, long b,
string c, string d, string e, string f, long g, string h, stringbuilder i,
ref long j, ref long k );
请帮忙,我已经花了一整天的时间:p....
最后,我使用自动项目转换器(从 VB6 到 VB.NET 2008)将函数调用转换为 VB.NET 库,并使用 C# 引用调用它。
谢谢。