C# Complex ToString(String)
Description
Complex ToString(String)
Converts the value of the current
complex number to its equivalent string representation in Cartesian form
by using the specified format for its real and imaginary parts.
Syntax
Complex.ToString(String)
has the following syntax.
public string ToString(
string format
)
Parameters
Complex.ToString(String)
has the following parameters.
format
- A standard or custom numeric format string.
Returns
Complex.ToString(String)
method returns The string representation of the current instance in Cartesian form.
Example
using System;/*from ww w. java 2s . c om*/
using System.Numerics;
public class Example
{
public static void Main()
{
Complex[] c = { new Complex(17.3, 14.1),
new Complex(-1.154, -1.002) };
string[] formats = { "F2", "N2", "G5" };
foreach (Complex c1 in c)
{
foreach (string format in formats)
Console.WriteLine("{0}: {1} ", format, c1.ToString(format));
Console.WriteLine();
}
}
}
The code above generates the following result.