Format complex number with standard format letters in CSharp
Description
The following code shows how to format complex number with standard format letters.
Example
/*from w w w .ja va 2s . com*/
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));
}
}
}
The code above generates the following result.