There is a Complex
struct that should do what you need:
Complex c = Complex.Sqrt(-25); // has a value of approximately 0 + 5i
(There's an implicit conversion from most number types, including int
, to Complex
. It works how you'd probably expect: the number is taken as the real part, and the imaginary part is 0. This is how -25
is a valid parameter to Complex.Sqrt(Complex)
.)