Complex.Explicit Operator

Definisi

Menentukan konversi eksplisit antara Complex objek dan jenis lain.

Overload

Explicit(UInt128 to Complex)

Secara eksplisit mengonversi nilai menjadi UInt128 bilangan kompleks presisi ganda.

Explicit(BigInteger to Complex)

Menentukan konversi BigInteger eksplisit nilai ke bilangan kompleks.

Explicit(Decimal to Complex)

Menentukan konversi Decimal eksplisit nilai ke bilangan kompleks.

Explicit(Int128 to Complex)

Secara eksplisit mengonversi nilai menjadi Int128 bilangan kompleks presisi ganda.

Explicit(UInt128 to Complex)

Sumber:
Complex.cs
Sumber:
Complex.cs
Sumber:
Complex.cs

Penting

API ini bukan kompatibel CLS.

Secara eksplisit mengonversi nilai menjadi UInt128 bilangan kompleks presisi ganda.

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

Parameter

value
UInt128

Nilai yang akan dikonversi.

Mengembalikan

value dikonversi menjadi bilangan kompleks presisi ganda.

Atribut

Berlaku untuk

Explicit(BigInteger to Complex)

Sumber:
Complex.cs
Sumber:
Complex.cs
Sumber:
Complex.cs

Menentukan konversi BigInteger eksplisit nilai ke bilangan kompleks.

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

Parameter

value
BigInteger

Nilai yang akan dikonversi menjadi bilangan kompleks.

Mengembalikan

Bilangan kompleks yang memiliki komponen nyata sama dengan value dan komponen imajiner sama dengan nol.

Contoh

Contoh berikut mengilustrasikan konversi BigInteger eksplisit nilai ke Complex nilai.

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)

Keterangan

Operator konversi eksplisit menentukan jenis yang dapat dikonversi menjadi Complex objek. Pengkompilasi bahasa tidak melakukan konversi ini secara otomatis karena dapat melibatkan kehilangan data. Sebaliknya, mereka melakukan konversi hanya jika operator transmisi (dalam C#) atau fungsi konversi (seperti CType di Visual Basic) digunakan. Jika tidak, mereka menampilkan kesalahan pengkompilasi.

Konversi BigInteger nilai ke bagian nyata dari bilangan kompleks dapat mengakibatkan hilangnya presisi karena Double, yang merupakan jenis properti bilangan Real kompleks, memiliki lebih sedikit digit signifikan daripada BigInteger.

Jika konversi tidak berhasil karena BigInteger nilainya berada di luar rentang jenisDouble, operasi tidak melempar .OverflowException Sebaliknya, jika value kurang dari MinValue, hasilnya adalah bilangan kompleks yang memiliki Real nilai properti yang sama dengan NegativeInfinity. Jika value lebih besar dari MaxValue, hasilnya adalah bilangan kompleks yang memiliki Real nilai properti yang sama dengan PositiveInfinity.

Berlaku untuk

Explicit(Decimal to Complex)

Sumber:
Complex.cs
Sumber:
Complex.cs
Sumber:
Complex.cs

Menentukan konversi Decimal eksplisit nilai ke bilangan kompleks.

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

Parameter

value
Decimal

Nilai yang akan dikonversi menjadi bilangan kompleks.

Mengembalikan

Bilangan kompleks yang memiliki komponen nyata sama dengan value dan komponen imajiner sama dengan nol.

Contoh

Contoh berikut mengilustrasikan konversi Decimal eksplisit nilai ke Complex nilai.

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)

Keterangan

Operator konversi eksplisit menentukan jenis yang dapat dikonversi menjadi Complex objek. Pengkompilasi bahasa tidak melakukan konversi ini secara otomatis karena dapat melibatkan kehilangan data. Sebaliknya, mereka melakukan konversi hanya jika operator transmisi (dalam C#) atau fungsi konversi (seperti CType di Visual Basic) digunakan. Jika tidak, mereka menampilkan kesalahan pengkompilasi.

Konversi Decimal nilai ke bagian nyata dari bilangan kompleks dapat mengakibatkan hilangnya presisi karena Double, yang merupakan jenis properti bilangan Real kompleks, memiliki lebih sedikit digit signifikan daripada Decimal.

Berlaku untuk

Explicit(Int128 to Complex)

Sumber:
Complex.cs
Sumber:
Complex.cs
Sumber:
Complex.cs

Secara eksplisit mengonversi nilai menjadi Int128 bilangan kompleks presisi ganda.

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

Parameter

value
Int128

Nilai yang akan dikonversi.

Mengembalikan

value dikonversi menjadi bilangan kompleks presisi ganda.

Berlaku untuk