Showing posts with label CLR. Show all posts
Showing posts with label CLR. Show all posts

Saturday, February 23, 2008

int and Int32

Int32 and int are the same.

int is the 'C# type' that actually maps to the primitive type 'Int32' which is the actual FCL Type.

Any data types the compiler directly supports are called primitive types. Primitive types map directly to types existing in the Framework Class Library (FCL).

CLS ( Common Language Specification ) is a sub-set of the primitive types that are supported by all dot.net languages.

C# Primitives not CLS complaint:

  1. System.SByte - Signed 8 bit value
  2. System.UInt16
  3. System.UInt32
  4. System.UInt64

Type Spoofing and CLR

 

Type spoofing is the cause of many security breaches and
compromises an application's stability and robustness. Type safety is therefore an extremely
important part of the CLR.

 

CLR checks the type security at runtime

Casting Object to a specific type will compile all fine, but at run time an exception 'InvalidCastException' is thrown if the type boxed in Object cannot be converted to the specific type ( i.e is not of the specific type or its base type )

Use As Over Is : using Is and then casting results in type checking twice. Once for Is and then while casting the CLR does the default type check. To avoid this use the As operator.

Monday, February 18, 2008

Exceptions

Exceptions allow the developers to isolate the failure recovery code from the code required to get the work done.

CLR Compilers

Microsoft provides several compilers that produce the code targeting the runtime: C++/CLI, C# , Visual Basic.NET and JScript.

C++/CLI(Common Language Infrastructure) is Microsoft's language specification to supersede MC++ ( Managed Extensions for C++ )

Microsoft has a version of .NET available for FreeBSD, Windows and Mac OS X called the Shared Source CLI (Rotor).

Technology

Technology has evolved providing abstraction layers to developers to allow them to focus more on the problem by caring less on the micro implementation details. When there are various different technologies offering abstractions over different areas ( web,win, com, etc ) the developers face the challenge when integrating these together to make them talk to each other.

The dot net framework (CLR + FCL) offers all of these abstraction layers on a common platform (IL).

CLR offers an object oriented programming model that defines what types and objects are and how they behave.

FCL - Framework Class Library offers an object oriented API set that all applications use.