Mega Code Archive

 
Categories / C# / Data Types
 

Converts current complex number to string in Cartesian form by using the specified format for its real and imaginary parts

using System; using System.Numerics; public class Example {    public static void Main()    {       Complex[] c = { new Complex(1117.3, 1114.1), new Complex(-11.154, -17.002) };       string[] formats = { "F2", "N2", "G5" };        foreach (Complex c1 in c)       {          foreach (string format in formats)             Console.WriteLine("{0}: {1}    ", format, c1.ToString(format));       }                              } }