Mega Code Archive

 
Categories / C# Book / 02 Essential Types
 

0328 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)