當前位置: 首頁>>代碼示例>>C#>>正文


C# Complex.Equals方法代碼示例

本文整理匯總了C#中System.Complex.Equals方法的典型用法代碼示例。如果您正苦於以下問題:C# Complex.Equals方法的具體用法?C# Complex.Equals怎麽用?C# Complex.Equals使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在System.Complex的用法示例。


在下文中一共展示了Complex.Equals方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: Equals

 public void Equals()
 {
     Complex<double> actual = new Complex<double>(1, 2);
     Complex<double> expected = new Complex<double>(2, 3);
     Assert.True(actual.Equals(actual));
     Assert.AreEqual(actual.Equals(expected), expected.Equals(actual));
 }
開發者ID:WilliamRobertMontgomery,項目名稱:asp-dot-net-training-project,代碼行數:7,代碼來源:Tests.cs

示例2: Divide

 public void Divide()
 {
     Complex actual = number1.Divide(number2);
     Complex expected = new Complex((number1.re * number2.re + number1.im * number2.im) / (number2.re * number2.re + number2.im * number2.im), (number1.im * number2.re - number1.re * number2.im) / (number2.re * number2.re + number2.im * number2.im));
     Assert.True(expected.Equals(actual));
 }
開發者ID:WilliamRobertMontgomery,項目名稱:asp-dot-net-training-project,代碼行數:6,代碼來源:ComplexTest.cs

示例3: Main

        static void Main(string[] args)
        {
            try
            {
                Numbers[] n = new Numbers[6] { new Complex(), new Complex(2, 1), new Complex(2, 3),new Fraction(),  new Fraction(1), new Fraction(2,5) };
                Console.WriteLine("a=" + n[1].ToString());
                Console.WriteLine("b=" + n[2].ToString());
                n[0] = (Complex)n[1] + (Complex)n[2];
                Console.WriteLine("a+b=" + n[0].ToString());
                n[0] = (Complex)n[1] / (Complex)n[2];
                Console.WriteLine("a/b=" + n[0].ToString());
                n[0] = (Complex)n[1] - (Complex)n[2];
                Console.WriteLine("a-b=" + n[0].ToString());
                n[0] = (Complex)n[1] * (Complex)n[2];
                Console.WriteLine("a*b=" + n[0].ToString());
                Console.WriteLine("test=" + n[1].ToString());
                Console.WriteLine("спряжене= " + ((Complex)n[1]).conjugate());
                double n1 = 2.0;
                Console.WriteLine(((Complex)n[1]).Root(n1));
                Console.WriteLine(((Complex)n[1]).Pow(n1));

                Console.WriteLine("+++++++++++++++++++++++");


                Fraction a1 = new Fraction(1);
                Console.WriteLine("1+2/5=");
                Fraction b1 = new Fraction(2, 5);
                n[3] = (Fraction)n[4] + (Fraction)n[5];
                Console.WriteLine(n[3].ToString());
                Console.WriteLine("1-2/5=");
                n[3] = (Fraction)n[4] - (Fraction)n[5];
                Console.WriteLine(n[3].ToString());
                Console.WriteLine("1*2/5=");
                n[3] = (Fraction)n[4] * (Fraction)n[5];
                Console.WriteLine(n[3].ToString());
                Console.WriteLine("1 : 2/5=");
                n[3] = (Fraction)n[4] / (Fraction)n[5];
                Console.WriteLine(n[3].ToString());
                Console.WriteLine();
                Console.WriteLine("1<2/5");
                Console.WriteLine((Fraction)n[4] < (Fraction)n[5]);
                Console.WriteLine();
                Console.WriteLine("1>2/5");
                Console.WriteLine((Fraction)n[4] > (Fraction)n[5]);
                Console.WriteLine();
                Console.WriteLine("1<=2/5");
                Console.WriteLine((Fraction)n[4] <= (Fraction)n[5]);
                Console.WriteLine();
                Console.WriteLine("1>=2/5");
                Console.WriteLine((Fraction)n[4] >= (Fraction)n[5]);
                Console.WriteLine();
                Console.WriteLine("1==2/5");
                Console.WriteLine((Fraction)n[4] == (Fraction)n[5]);
                Console.WriteLine();
                Console.WriteLine("1!=2/5");
                Console.WriteLine((Fraction)n[4] != (Fraction)n[5]);
                Fraction mm = new Fraction(2, 2);
                Complex mn = new Complex(2, 2);
                if (mn.Equals(mm))
                    Console.WriteLine("+++");
                else
                    Console.WriteLine("---");
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }

        }
開發者ID:sem256,項目名稱:first_year,代碼行數:69,代碼來源:Program.cs


注:本文中的System.Complex.Equals方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。