Information Technology Reference
In-Depth Information
li3 = li1 - li2;
Console.WriteLine(" {0} - {1} = {2}",
li1.TheValue, li2.TheValue, li3.TheValue);
}
}
This code produces the following output:
li1: 10, li2: 26
-10 = 0
26 - 10 = 16
10 - 26 = 0
The typeof Operator
The
typeof
operator returns the
System.Type
object of any type given as its parameter. From
this object, you can learn the characteristics of the type. (There is only one
System.Type
object
for any given type.) The operator's characteristics are listed in Table 8-17.
The
typeof
operator is unary.
Table 8-17.
The typeof Operator
Operator
Description
typeof
Returns the
System.Type
object of a given type.
The following is an example of the syntax of the
typeof
operator.
Type
is a class in the
System
namespace.
Type t = typeof ( SomeClass )
You cannot overload the
typeof
operator, as that would defeat the .NET type-safety
mechanisms.