从C ++/CLI到C#的枚举 [英] Enum from C++/CLI to C#
本文介绍了从C ++/CLI到C#的枚举的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有以下托管课程
I have the following managed class
namespace Managed_DLL
{
public ref class AController
{
public:
delegate void didChangeListenerStatus(tListenerStatus status);
....
}
// header file
#if defined(_MANAGED)
namespace Managed_DLL
{
#define ENUMKEYWORD public enum
#else
#define ENUMKEYWORD typedef enum
#endif
ENUMKEYWORD tListenerStatus
{
kListenerStopped,
kListenerRunning,
kListenerFailed
} ;
}
我已经在dll预处理程序定义中定义了_MANAGED
在C#应用程序中,我已在其中一个类中将didChangeListenerStatus定义为
I have defined the _MANAGED in the dll preprocessor defines
In C# app I have defined the didChangeListenerStatus in one of classes as
using Managed_DLL
....
public void didChangeListenerStatus(tListenerStatus status)
{
Console.WriteLine(" didChangeListnerStatus called");
}
当我编译C#应用程序时,出现以下错误
When I compile the C# app it gives the following error
Error 4 'tListenerStatus' is inaccessible due to its protection level
Error 3 Inconsistent accessibility: parameter type 'tListenerStatus' is less accessible than method 'ADemo.ViewController.didChangeListenerStatus(tListenerStatus)
Error 6 The type or namespace name 'tListenerStatus' could not be found (are you missing a using directive or an assembly reference?)
请帮忙.预先感谢.
Please help. Thanks in advance.
推荐答案
尝试此代码.
try this code.
public ENUMKEYWORD tListenerStatus
{
kListenerStopped,
kListenerRunning,
kListenerFailed
} ;
默认情况下,所有类都是私有的.
by default all class are private.
为什么要重复问题?请参阅我对相同问题的回答.
—SA
Why do you repeat questions? See my answer to your identical Question.
—SA
这篇关于从C ++/CLI到C#的枚举的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文