Penjelasan Overloadable Operators C# Asp.Net


C # memungkinkan tipe yang ditentukan user untuk membebani operator dengan mendefinisikan fungsi member statis menggunakan keyword operator. Tidak semua operator bisa overlod, bagaimanapun, dan yang lainnya memiliki batasan, seperti tercantum dalam tabel ini:

OperatorsOverloadability
+, -, !, ~, ++, --, true, falseThese unary operators can be overloaded.
+, -, *, /, %, &, |, ^, <<, >>These binary operators can be overloaded.
==, !=, <, >, <=, >=The comparison operators can be overloaded (but see the note that follows this table).
&&, ||The conditional logical operators cannot be overloaded, but they are evaluated using & and |, which can be overloaded.
[]The array indexing operator cannot be overloaded, but you can define indexers.
(T)xThe cast operator cannot be overloaded, but you can define new conversion operators (see explicit and implicit).
+=, -=, *=, /=, %=, &=, |=, ^=, <<=, >>=Assignment operators cannot be overloaded, but +=, for example, is evaluated using +, which can be overloaded.
=, ., ?:, ??, ->, =>, f(x), as, checked, unchecked, default, delegate, is, new, sizeof, typeofThese operators cannot be overloaded.
Previous
Next Post »