C# 将结构列表从c转换为c++;

C# 将结构列表从c转换为c++;,c#,c++,visual-c++,clr,C#,C++,Visual C++,Clr,我有下面的c代码 static void Main(字符串[]args) { 列表投票=新列表(); } 公共结构结果 { 公共int Vote1; 公共int Vote2; 公共int Vote3; 公众候选人选区条件; }; 公开课候选人 { 公开候选人() { } 私有字符串名称; 公共字符串名 { 获取{返回名称;} 设置{name=value;} } 私有字符串lastName; 公共字符串姓氏 { 获取{return lastName;} 设置{lastName=value;} }

我有下面的c代码

static void Main(字符串[]args)
{
列表投票=新列表();
}
公共结构结果
{
公共int Vote1;
公共int Vote2;
公共int Vote3;
公众候选人选区条件;
};
公开课候选人
{
公开候选人()
{
}
私有字符串名称;
公共字符串名
{
获取{返回名称;}
设置{name=value;}
}
私有字符串lastName;
公共字符串姓氏
{
获取{return lastName;}
设置{lastName=value;}
}
}

<>我想把代码转换成VisualC++ + CLR,谢谢

< p>这里是你的代码直接翻译成C++ /CLI:< /P>
using namespace System;
using namespace System::Collections::Generic;

public ref class Candidate
{
public:  
    Candidate()
    {
    }
    property String^ Name
    {
        String^ get() { return this->name; }
        void set(String^ value) { this->name = value; }
    }
    property String^ LastName
    {
       String^ get() { return this->lastName; }
       void set(String^ value) { this->lastName = value; }
    }
private:
    String^ name;
    String^ lastName;
};

public value class Results
{
public:
    Int32 Vote1;
    Int32 Vote2;
    Int32 Vote3;
    Candidate^ precinctCandidate;
};

int main(array<String^>^ args)
{
    List<Results> votes = gcnew List<Results>();
    return 0;
}
使用名称空间系统;
使用命名空间System::Collections::Generic;
公开参考类候选人
{
公众:
候选人()
{
}
属性字符串^Name
{
字符串^get(){返回此->名称;}
无效集(字符串^value){this->name=value;}
}
属性字符串^LastName
{
字符串^get(){返回此->lastName;}
无效集(字符串^value){this->lastName=value;}
}
私人:
字符串^name;
字符串^lastName;
};
公众价值观课程成绩
{
公众:
Int32 Vote1;
Int32-Vote2;
Int32 Vote3;
候选人^选区条件;
};
int main(数组^args)
{
列表投票=gcnew List();
返回0;
}

谢谢Nick,您提到您使用Reflector或类似的工具获得此代码,但我找不到,请您告诉mw这是什么。ThanksI手工编写了上述代码。另一个人发布了另一个答案,它已经被从“反射镜”的C++反编译器获得的“旧语法”管理C++删除。你可以在这里找到反射镜:。
using namespace System;
using namespace System::Collections::Generic;

public ref class Candidate
{
public:  
    Candidate()
    {
    }
    property String^ Name
    {
        String^ get() { return this->name; }
        void set(String^ value) { this->name = value; }
    }
    property String^ LastName
    {
       String^ get() { return this->lastName; }
       void set(String^ value) { this->lastName = value; }
    }
private:
    String^ name;
    String^ lastName;
};

public value class Results
{
public:
    Int32 Vote1;
    Int32 Vote2;
    Int32 Vote3;
    Candidate^ precinctCandidate;
};

int main(array<String^>^ args)
{
    List<Results> votes = gcnew List<Results>();
    return 0;
}