I have the following c# code
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; }
}
}
I want to convert that code into Visual c++ CLR, Thanks
Here is a direct translation of your code to 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;
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.