Articles → CSHARP → Complex Struct In C#
Complex Struct In C#
Purpose
- x and y are real numbers
- i is the imaginary unit
Example
using System.Numerics;
// By passing two values to it's constructor
// The first value represents the real part
// The second value represents the imaginary part
Complex complexOne = new Complex(3, 14);
Console.WriteLine("Initializing the complex variable by passing 2 values in the constructor");
Console.WriteLine(complexOne);
Complex complexTwo = 3.14;
Console.WriteLine("Initializing the complex variable assign the double value");
Console.WriteLine(complexTwo);
Console.ReadLine();
Output
Click to Enlarge