Convert complex number to string in Cartesian form in CSharp

Description

The following code shows how to convert complex number to string in Cartesian form.

Example


using System;/*from  w w w .  j  a  v a  2s  .c  o  m*/
using System.Globalization;
using System.Numerics;

public class Example
{
   public static void Main()
   {
      Complex[] c = { new Complex(1.3, 1.1), new Complex(-11.1, -1.2) };
      CultureInfo[] cultures = { new CultureInfo("en-US"), 
                                 new CultureInfo("fr-FR") };
      foreach (Complex c1 in c)
      {
         foreach (CultureInfo culture in cultures)
            Console.Write("{0} ({1})    ", c1.ToString(culture), culture.Name);

         Console.WriteLine();
      }                          
   }
}

The code above generates the following result.





















Home »
  C# Tutorial »
    Data Types »




C# Data Types
Bool
Byte
Char
Decimal
Double
Float
Integer
Long
Short
String
C# Array
Array Example
Byte Array
C# Standard Data Type Format
BigInteger
Complex
Currency
DateTime
DateTimeOffset
DateTime Format Parse Convert
TimeSpan
TimeZone
Enum
Null
tuple
var