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

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

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

v1,v2我该定义一个什么类型的呀???
...全文
261 3 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
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

111,092

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • AIGC Browser
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

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

试试用AI创作助手写篇文章吧