怎么样在c#调用dll中参数为ref object 类型的函数呀?

wsmt 2004-04-30 12:24:58
请问我需要怎样去放入这样一个参数呀?

如 f1(ref object v1,ref object v2){}

v1,v2我该定义一个什么类型的呀???
...全文
147 3 点赞 打赏 收藏 举报
写回复
3 条回复
切换为时间正序
当前发帖距今超过3年,不再开放新的回复
发表回复
wsmt 2004-04-30
刚刚解决了,谢谢,还是给分!
  • 打赏
  • 举报
回复
BearRui 2004-04-30
object obj1,obj2

f1(ref obj1,ref obj2){}
  • 打赏
  • 举报
回复
reformer 2004-04-30
示例
// cs_ref.cs
using System;
public class MyClass
{
public static void TestRef(ref char i)
{
// The value of i will be changed in the calling method
i = 'b';
}

public static void TestNoRef(char i)
{
// The value of i will be unchanged in the calling method
i = 'c';
}

// This method passes a variable as a ref parameter; the value of the
// variable is changed after control passes back to this method.
// The same variable is passed as a value parameter; the value of the
// variable is unchanged after control is passed back to this method.
public static void Main()
{

char i = 'a'; // variable must be initialized
TestRef(ref i); // the arg must be passed as ref
Console.WriteLine(i);
TestNoRef(i);
Console.WriteLine(i);
}
}
输出
b
b
  • 打赏
  • 举报
回复
相关推荐
发帖
C#
加入

10.6w+

社区成员

.NET技术 C#
申请成为版主
帖子事件
创建了帖子
2004-04-30 12:24
社区公告

让您成为最强悍的C#开发者