Complex number operators

The standard arithmetic operators are overloaded to work on Complex numbers:


using System;
using System.Numerics;

class Sample
{
    public static void Main()
    {
        Complex c1 = new Complex(2, 3.5);
        Complex c2 = new Complex(3, 0);

        Console.WriteLine(c1 + c2);
        Console.WriteLine(c1 * c2);  
    }
}

The output:


(5, 3.5)
(6, 10.5)
java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.