C# / VB.Net 问题:VB.Net 填充字符串数组,但 C# 不填充
我正在使用引用的 VB6 DLL。问题在于方法/函数调用的结果不相同。下面是代码示例:
首先VB.Net
Dim Validations() As String
myErr = myEntry.ValidateLine(Validations)
当验证失败时,字符串数组Validations 会填充错误描述字符串。我尝试在 C# 中完成相同的任务:
private string[] valArray = null;
sdkError = sdkEntry.ValidateLine(valArray);
有人知道为什么我无法让 C# 填充字符串数组吗?
另外,VB中的函数是通过引用System.Array ...
ValidateLine(ref System.Array ValErrors)来调用的,也许它与此有关?
I'm working with referenced VB6 DLL's. The problem is that the results of a method/function call are not the same. Below the code examples:
First VB.Net
Dim Validations() As String
myErr = myEntry.ValidateLine(Validations)
When validation fails, the string array Validations is filled with the error description string. I've tried to accomplish the same in C#:
private string[] valArray = null;
sdkError = sdkEntry.ValidateLine(valArray);
Does anyone have an idea why I can't get C# to fill the string array?
Additionally, the function in VB is called with ref to a System.Array ...
ValidateLine(ref System.Array ValErrors), perhaps it has something to do with this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我的猜测是 VB 通过引用隐式传递变量。您可以尝试在 C# 中执行相同的操作:(
请注意,目前还不清楚如何调用 VB DLL。)
My guess is that VB is implicitly passing your variable by reference. You could try doing the same thing in C#:
(It's not immediately clear how you're invoking the VB DLL, mind you.)
您的 VB 创建空数组,您的 C# 创建空数组。我猜测 VB dll 需要一个非空值。
尝试将您的 C# 替换为:
Your VB creates and empty array, your C# creates a null array. I'm guessing the VB dll needs a non null value.
Try swapping your C# to this: