Wednesday, 26 February 2014

Typeof(Type) Operator Vs GetType() Method Vs IS Operator Vs SizeOf Operator

 

 

Typeof

Used to obtain the System.Type object for a type. A typeof expression takes the following form:

image

 

image

image

 

 

 

Get Type

 

This sample uses the GetType method to determine the type that is used to contain the result of a numeric calculation. This depends on the storage requirements of the resulting number.

image

 

 

Is Operator

Checks if an object is compatible with a given type. For example, the following code can determine if an object is an instance of the MyObject type, or a type that derives from MyObject:

image

 

image

image

 

 

 

SizeOf Operator

Used to obtain the size in bytes for an unmanaged type. Unmanaged types include the built-in types that are listed in the table that follows, and also the following:

 

image

 

image

 

image

 

 

 

Blogger Labels: Typeof,Type,Operator,GetType,Method,System,calculation,storage,requirements,Checks,example,instance,MyObject

No comments:

Post a Comment