Complex.Explicit 運算子

定義

定義 Complex 物件與另一個類型之間的明確轉換。

多載

Explicit(UInt128 to Complex)

明確地將值轉換成 UInt128 雙精確度複數。

Explicit(BigInteger to Complex)

定義從 BigInteger 值到複數的明確轉換。

Explicit(Decimal to Complex)

定義從 Decimal 值到複數的明確轉換。

Explicit(Int128 to Complex)

明確地將值轉換成 Int128 雙精確度複數。

Explicit(UInt128 to Complex)

來源:
Complex.cs
來源:
Complex.cs
來源:
Complex.cs

重要

此 API 不符合 CLS 規範。

明確地將值轉換成 UInt128 雙精確度複數。

public:
 static explicit operator System::Numerics::Complex(UInt128 value);
[System.CLSCompliant(false)]
public static explicit operator System.Numerics.Complex (UInt128 value);
[<System.CLSCompliant(false)>]
static member op_Explicit : UInt128 -> System.Numerics.Complex
Public Shared Narrowing Operator CType (value As UInt128) As Complex

參數

value
UInt128

要進行轉換的值。

傳回

value 轉換成雙精確度複數。

屬性

適用於

Explicit(BigInteger to Complex)

來源:
Complex.cs
來源:
Complex.cs
來源:
Complex.cs

定義從 BigInteger 值到複數的明確轉換。

public:
 static explicit operator System::Numerics::Complex(System::Numerics::BigInteger value);
public static explicit operator System.Numerics.Complex (System.Numerics.BigInteger value);
static member op_Explicit : System.Numerics.BigInteger -> System.Numerics.Complex
Public Shared Narrowing Operator CType (value As BigInteger) As Complex

參數

value
BigInteger

要轉換成複數的值。

傳回

實數部分等於 value 及虛數部分等於零的複數。

範例

下列範例說明將值Complex明確轉換成BigInteger值。

BigInteger[] numbers= {
                 ((BigInteger) Double.MaxValue) * 2,
                 BigInteger.Parse("901345277852317852466891423"),
                 BigInteger.One };
foreach (BigInteger number in numbers)
{
  Complex c1 = (Complex) number;
   Console.WriteLine(c1);
}
// The example displays the following output:
//       (Infinity, 0)
//       (9.01345277852318E+26, 0)
//       (1, 0)
Dim numbers() As BigInteger = {
                 CType(Double.MaxValue, BigInteger) * 2, 
                 BigInteger.Parse("901345277852317852466891423"), 
                 BigInteger.One } 
For Each number In numbers
  Dim c1 As System.Numerics.Complex = CType(number, 
                                    System.Numerics.Complex)
   Console.WriteLine(c1)
Next        
' The example displays the following output:
'       (Infinity, 0)
'       (9.01345277852318E+26, 0)
'       (1, 0)

備註

明確轉換運算子會定義可轉換成 Complex 物件的類型。 語言編譯程式不會自動執行此轉換,因為它可能會牽涉到數據遺失。 相反地,只有在 C#) 中的轉換運算子 (,或使用 Visual Basic) 之類的 CType 轉換函式 (時,才會執行轉換。 否則,它們會顯示編譯程序錯誤。

將值轉換成BigInteger複數的實數部分可能會導致精確度遺失,因為 是複數屬性類型的 RealDouble其有效位數比 BigInteger少。

如果轉換失敗, BigInteger 因為值超出型別的範圍 Double ,則作業不會擲回 OverflowException。 相反地,如果 value 小於 MinValue,則結果為屬性值等於 NegativeInfinity的複數Real。 如果 value 大於 MaxValue,則結果為屬性值等於PositiveInfinity的複數Real

適用於

Explicit(Decimal to Complex)

來源:
Complex.cs
來源:
Complex.cs
來源:
Complex.cs

定義從 Decimal 值到複數的明確轉換。

public:
 static explicit operator System::Numerics::Complex(System::Decimal value);
public static explicit operator System.Numerics.Complex (decimal value);
static member op_Explicit : decimal -> System.Numerics.Complex
Public Shared Narrowing Operator CType (value As Decimal) As Complex

參數

value
Decimal

要轉換成複數的值。

傳回

實數部分等於 value 及虛數部分等於零的複數。

範例

下列範例說明將值Complex明確轉換成Decimal值。

decimal[] numbers = { Decimal.MinValue, -18.35m, 0m, 1893.019m,
                      Decimal.MaxValue };
foreach (decimal number in numbers)
{
   System.Numerics.Complex c1 = (System.Numerics.Complex) number;
   Console.WriteLine("{0,30}  -->  {1}", number, c1);
}
// The example displays the following output:
//    -79228162514264337593543950335  -->  (-7.92281625142643E+28, 0)
//                            -18.35  -->  (-18.35, 0)
//                                 0  -->  (0, 0)
//                          1893.019  -->  (1893.019, 0)
//     79228162514264337593543950335  -->  (7.92281625142643E+28, 0)
Dim numbers() As Decimal = { Decimal.MinValue, -18.35d, 0d, 1893.019d, 
                             Decimal.MaxValue }
For Each number In numbers
   Dim c1 As System.Numerics.Complex = CType(number, 
                                             System.Numerics.Complex)
   Console.WriteLine("{0,30}  -->  {1}", number, c1)
Next   
' The example displays the following output:
'    -79228162514264337593543950335  -->  (-7.92281625142643E+28, 0)
'                            -18.35  -->  (-18.3500003814697, 0)
'                                 0  -->  (0, 0)
'                          1893.019  -->  (1893.01904296875, 0)
'     79228162514264337593543950335  -->  (7.92281625142643E+28, 0)

備註

明確轉換運算子會定義可轉換成 Complex 物件的類型。 語言編譯程式不會自動執行此轉換,因為它可能會牽涉到數據遺失。 相反地,只有在 C#) 中的轉換運算子 (,或使用 Visual Basic) 之類的 CType 轉換函式 (時,才會執行轉換。 否則,它們會顯示編譯程序錯誤。

將值轉換成Decimal複數的實數部分可能會導致精確度遺失,因為 是複數屬性類型的 RealDouble其有效位數比 Decimal少。

適用於

Explicit(Int128 to Complex)

來源:
Complex.cs
來源:
Complex.cs
來源:
Complex.cs

明確地將值轉換成 Int128 雙精確度複數。

public:
 static explicit operator System::Numerics::Complex(Int128 value);
public static explicit operator System.Numerics.Complex (Int128 value);
static member op_Explicit : Int128 -> System.Numerics.Complex
Public Shared Narrowing Operator CType (value As Int128) As Complex

參數

value
Int128

要進行轉換的值。

傳回

value 轉換成雙精確度複數。

適用於