问题描述
我正在尝试从CLR和C#创建基于事件的调用。但我对此并不了解。我将在下面解释我的代码
我的解决方案有一个3个单独的项目
Project1(C ++ with CLR支持构建) - > Project2(带有CLR支持构建的C ++) - > Project3(C#)
Project1(支持CLR Build的C ++)
I'm trying to create event based call from CLR and C#. But I don't have a idea about it. I'll explain my code below
My solution has a 3 separate project
Project1 (C++ with CLR support build) -> Project2(C++ with CLR support build)-> Project3 (C#)
Project1 (C++ with CLR Build support)
class MB
{
virtual void ShowMessage()
{
}
};
class MA
{
MB obj;
public:
void PrintMessage()
{
obj.ShowMessage()
}
};
Project2(C ++使用CLR Build支持)
Project2 (C++ with CLR Build support)
class WA : public MB
{
virtual void ShowMessage() override
{
}
};
class WB
{
WA wObj;
void GetData()
{
wObj= new MB();
wObj.PrintMessage();
}
};
基本上如果我调用wObj.PrintMessage()函数那么它将调用WA类ShowMessage()函数。直到这一点它才能正常工作。
Project3(C#)
Basically if i call wObj.PrintMessage() function then it will call WA class ShowMessage() function. Till this point it's working fine.
Project3 (C#)
Class MC
{
void PrintMessage()
{
}
};
每当调用MA.PrintMessage(Project1)函数时,我都会尝试调用MC.PrintMessage()函数。
I'm trying to invoke MC.PrintMessage() function whenever the MA.PrintMessage (Project1) function called.
推荐答案
这篇关于使用CLR和C#处理委托事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!