当前位置: 首页>>代码示例>>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;未经允许,请勿转载。