Converts current complex number to string in Cartesian form by using the specified format for its real and imaginary parts. : Complex « Data Types « C# / C Sharp






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));
      }                          
   }
}

   
  








Related examples in the same category

1.A Complex Number ClassA Complex Number Class
2.Complex number class
3.Class to do math on complex numbers.
4.Initializes a new instance of the Complex structure using the specified real and imaginary values.
5.Complex Structure represents a complex number.
6.Assign a Double to a complex number
7.Cast a Decimal to a complex number
8.Assign the return value of a method to a Complex variable
9.Assign the value returned by an operator to a Complex variable
10.Instantiate a complex number from its polar coordinates
11.Complex.Exp
12.Complex.Sqrt
13.Divide and multiply
14.Gets the absolute value (or magnitude) of a complex number.
15.Returns the angle that is the arc cosine of the specified complex number.
16.Adds two complex numbers and returns the result.
17.Adds two complex numbers.
18.Returns the angle that is the arc sine of the specified complex number.
19.Returns the angle that is the arc tangent of the specified complex number.
20.Computes the conjugate of a complex number and returns the result.
21.Divides one complex number by another and returns the result.
22.Returns a value that indicates whether the current instance and a specified complex number have the same value.
23.Returns e raised to the power specified by a complex number.
24.Creates a complex number from a point's polar coordinates.
25.Gets the imaginary component of the current Complex object.
26.Returns a new Complex instance with a real number equal to zero and an imaginary number equal to one.
27.Returns the product of two complex numbers.
28.Returns the additive inverse of a specified complex number.
29.Returns a new Complex instance with a real number equal to one and an imaginary number equal to zero.
30.Returns a specified complex number raised to a power specified by a double-precision floating-point number.
31.Returns the multiplicative inverse of a complex number.
32.Subtracts one complex number from another and returns the result.
33.Converts current complex number to string in Cartesian form by using the specified culture-specific formatting information.
34.Converts complex number to string representation in Cartesian form by using the specified format and culture-specific format information for its real and imaginary parts.
35.Converts the value of the current complex number to its equivalent string representation in Cartesian form.
36.Returns a new Complex instance with a real number equal to zero and an imaginary number equal to zero.