C++到C#移植

Pas*_*ada 2 c# c++

如何将此代码(c ++)移植到c#?

template <class entity_type>
class State {
public:
    virtual void Enter(entity_type*) = 0;
    virtual void Execute(entity_type*) = 0;
    virtual void Exit(entity_type*) = 0;
    virtual ~State() { }
};
Run Code Online (Sandbox Code Playgroud)

Roo*_*ook 6

假设它真的是一个纯粹的抽象基类,它的外观如下:

interface State<T>
{
    void Enter(T arg);
    void Execute(T arg);
    void Exit(T arg);
};
Run Code Online (Sandbox Code Playgroud)

但传递约定的确切参数是尴尬的.如果不知道你想要做什么,很难确切地说你应该在C#中做些什么.可能,void FunctionName(ref T arg)可能更合适.