【发布时间】:2012-06-22 15:17:14
【问题描述】:
我需要在 Visual C++ 中编写一个接口,将在 C# 项目中使用。我需要在 C# 中使用 out 参数,我将如何制作 C++ 签名?
类似C++的代码
public interface class Iface
{
public:
System::Object^ Method([out] bool there);
};
和C#必须是
public class TestObj : Library.Iface
{
object Library.Iface.Method(out bool there)
{
there = true;
return null;
}
}
我将如何编写我的 C++ 接口?
【问题讨论】:
-
我相信 C++/CLI 只会为您提供普通和
ref参数(当您使用%托管引用符号时)。 -
你为什么要使用
out为什么你的代码有问题?我看到的一个问题是您将其声明为接口类,这告诉我这是不正确的。 -
谢谢。我在 C++/CLI 方面没有太多经验