Перегрузка операций сравнения в С#

Я хочу реализовать перегрузку операций сравнения объектов класса. В данном случае у меня двоичная матрица, хочу сравнить суммы диагоналей(т.е. >, <, !=, ==, >=, <=). Сразу говорю, изучать С# начал недавно, поэтому не судите строго, но я полностью открыт для критике.

 using System;

namespace Task_4
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.BackgroundColor = ConsoleColor.Gray;
            Console.ForegroundColor = ConsoleColor.Black;
            Console.Clear();
            int[,] matr = new int[2, 2];
            Console.WriteLine("Матрица:");
            Initialize(matr);
            Console.WriteLine();
            Console.WriteLine("Минимальный элемент: {0}", min(matr));
            Console.WriteLine("Максимальный элемент: {0}", max(matr));
            Console.WriteLine();
            Console.WriteLine("Сумма всех элементов: {0}", sum(matr));
            Console.WriteLine();
            Console.WriteLine("Сумма элементов первой диагонали: {0}", sumD1(matr));
            Console.WriteLine("Сумма элементов второй диагонали: {0}", sumD2(matr));
            Console.WriteLine();
            Console.WriteLine("Произведение всех элементов: {0}", prod(matr));
            Console.WriteLine();
            Console.WriteLine("Заполнение матрицы нулями:");
            Cancellation(matr);
            Console.ReadKey();
        }

        static void Initialize(int[,] matr)
        {
            int value = 1;
            for (int i = 0; i < matr.GetLength(0); i++)
            {
                for (int j = 0; j < matr.GetLength(0); j++)
                {
                    matr[i, j] = value;
                    value++;
                    Console.Write(matr[i, j] + "\t");
                }
                Console.WriteLine();
            }
        }

        static int min(int[,] matr)
        {
            int min = matr[0, 0];
            for (int i = 0; i < matr.GetLength(0); i++)
            {
                for (int j = 0; j < matr.GetLength(0); j++)
                {
                    if (min > matr[i, j]) min = matr[i, j];
                }
            }
            return min;
        }

        static int max(int[,] matr)
        {
            int max = matr[0, 0];
            for (int i = 0; i < matr.GetLength(0); i++)
            {
                for (int j = 0; j < matr.GetLength(0); j++)
                {
                    if (max < matr[i, j]) max = matr[i, j];
                }
            }
            return max;
        }

        static int sum(int[,] matr)
        {
            int sum = 0;
            for (int i = 0; i < matr.GetLength(0); i++)
            {
                for (int j = 0; j < matr.GetLength(0); j++)
                {
                    sum += matr[i, j];
                }
            }
            return sum;
        }

        static int prod(int[,] matr)
        {
            int prod = 1;
            for (int i = 0; i < matr.GetLength(0); i++)
            {
                for (int j = 0; j < matr.GetLength(0); j++)
                {
                    prod *= matr[i, j];
                }
            }
            return prod;
        }

        static int sumD1(int[,] matr)
        {
            int sumD1 = 0;
            for (int i = 0; i < matr.GetLength(0); i++) sumD1 += matr[i, i];
            return sumD1;
        }

        static int sumD2(int[,] matr)
        {
            int sumD2 = 0;
            for (int j = 0; j < matr.GetLength(0); j++) sumD2 += matr[j, j];
            return sumD2;
        } 

        static void Cancellation(int[,] matrix)
        {
            int[,] Mat = new int[matrix.GetLength(0), matrix.GetLength(0)];
            for (int i = 0; i < matrix.GetLength(0); i++)
            {
                for (int j = 0; j < matrix.GetLength(0); j++)
                {
                        Mat[i, j] = 0;
                        Console.Write(Mat[i, j] + "\t");
                }
                Console.WriteLine();
            }
        }       
    }
}

введите сюда описание изображения


Ответы (0 шт):