C# Complex Complex
Description
Complex Complex
Initializes a new instance of the Complex
structure using the specified real and imaginary values.
Syntax
Complex.Complex
has the following syntax.
public Complex(
double real,
double imaginary
)
Parameters
Complex.Complex
has the following parameters.
real
- The real part of the complex number.imaginary
- The imaginary part of the complex number.
Example
The following example instantiates two complex numbers.
//from w w w . j a v a 2 s. co m
using System;
using System.Numerics;
public class Example
{
public static void Main()
{
Complex complex1 = new Complex(1.34, 12.87);
Complex complex2 = new Complex(8.76, 5.19);
Console.WriteLine("{0} + {1} = {2}", complex1, complex2,
complex1 + complex2);
Console.WriteLine("{0} - {1} = {2}", complex1, complex2,
complex1 - complex2);
Console.WriteLine("{0} * {1} = {2}", complex1, complex2,
complex1 * complex2);
Console.WriteLine("{0} / {1} = {2}", complex1, complex2,
complex1 / complex2);
}
}
The code above generates the following result.