:这段小 c++ 程序,如何改为 C# 的,多谢2
求助:这段小 c++ 程序,怎么改为 C# 的,谢谢2!
请教:
c++ 里
struct Ranking
{
string name; //名字
int loops; //圈数
int point; //已经到达的 ID
bool operator >= (Ranking const& that) const
{
if (loops > that.loops)
{
return true;
}
return false;
}
};
C# 里怎么写?
谢谢!
------解决思路----------------------
c#重载运算符必须成对出现,而且必须定义为是public static
请教:
c++ 里
struct Ranking
{
string name; //名字
int loops; //圈数
int point; //已经到达的 ID
bool operator >= (Ranking const& that) const
{
if (loops > that.loops)
{
return true;
}
return false;
}
};
C# 里怎么写?
谢谢!
------解决思路----------------------
c#重载运算符必须成对出现,而且必须定义为是public static
public struct Ranking
{
string name; //名字
int loops; //圈数
int point; //已经到达的 ID
public static bool operator >= (Ranking x, Ranking y)
{
if (x1.loops >= y.loops)
{
return true;
}
return false;
}
public static bool operator <= (Ranking x, Ranking y)
{
if (x1.loops <= y.loops)
{
return true;
}
return false;
}
}