我有以下c#代码
static void Main(string[] args)
{
List<Results> votes = new List<Results>();
}
public struct Results
{
public int Vote1;
public int Vote2;
public int Vote3;
public Candidate precinctCandidate;
};
public class Candidate
{
public Candidate()
{
}
private string name;
public string Name
{
get { return name; }
set { name = value; }
}
private string lastName;
public string LastName
{
get { return lastName; }
set { lastName = value; }
}
}
我想将该代码转换为Visual c + + CLR,谢谢
答案 0 :(得分:2)
以下是您的代码直接转换为C ++ / CLI:
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;
}