本文介绍了C#如何比较两个三角形与运算符>的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有Triangle Class,我需要比较两个三角形,我试过但它给了我错误。我的错是什么?



我尝试过:



I have Triangle Class, i need to compare two triangle with each other,i tried but it have given me error.What's my mistake?

What I have tried:

class Triangle
    {
        public int koxm1;
        public int koxm2;
        public int koxm3;
        public Triangle(int a, int b, int c)
        {
            this.koxm1 = a;
            this.koxm2 = b;
            this.koxm3 = c;
        }
        static public bool operator>(Erankyun a, Erankyun b)
        {
            return a.koxm1 + a.koxm2 + a.koxm3 > b.koxm1 + b.koxm2 + b.koxm3;
        }
    }







 static void Main(string[] args)
{
Erankyun e1 = new Erankyun(1,2,3);
Erankyun e2 = new Erankyun(1,4,3);

Console.WriteLine(e1 > e2); // false
}

推荐答案



这篇关于C#如何比较两个三角形与运算符>的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-28 23:26