INTRODUCTION TO C#
CLR and JIT compiling :
• C#, like Java, is executed indirectly through an abstract computer architecture called the CLR.
– CLR => Common Language Runtime.
– Abstract, but well defined.
• C# programs are compiled to an IL.
– Also called MSIL, CIL (Common Intermediate Language) or bytecode.
• The CLR transforms the CIL to assembly instructions for a particular hardware architecture.
– This is termed jit’ing or Just-in-time compiling.
– Some initial performance cost, but the jitted code is cached for further execution.
– The CLR can target the specific architecture in which the code is executing, so some performance gains are possible.
• All .NET languages compile to the same CIL.
• Each language actually uses only a subset of the CIL.
• The least-common denominator is the Common Language Specification (CLS).
• So, if you want to use your C# components in Visual Basic you need to program to the CLS.
CLR versus CLI :
• CLR is actually an implementation by Microsoft of the CLI (Common Language Infrastructure) .
• CLI is an open specification.
• CLR is really a platform specific implementation.
The CLR Architecture :
Common Language Infrastructure :
• CLI allows for cross-language development.
• Four components:
– Common Type System (CTS)
– Meta-data in a language agnostic fashion.
– Common Language Specification – behaviors that all languages need to follow.
– A Virtual Execution System (VES).
Common Type System (CTS) :
• A specification for how types are defined and how they behave.
– no syntax specified
• A type can contain zero or more members:
– Field
– Method
– Property
– Event
• CTS also specifies the rules for visibility and access to members of a type:
– Private
– Family
– Family and Assembly
– Assembly
– Family or Assembly
– Public
• Other rules
– Object life-time
– Inheritance
– Equality (through System.Object)
• Languages often define aliases
• For example
– CTS defines System.Int32 – 4 byte integer
– C# defines int as an alias of System.Int32
– C# aliases System.String as string.
Common Language System :
• A specification of language features
– how methods may be called
– when constructors are called
– subset of the types in CTS which are allowed
• For example
– Code that takes UInt32 in a public method
– UInt32 is not in the CLS
• Can mark classes as CLS-compliant
– not marked is assumed to mean not compliant.
CLS versus CLR :
Built-in Types :
Blittable types :
• Most of these types are blittable, meaning their memory layout is consistent across languages and hence, support interoperability.
• The types bool, char, object and string are not and must be Marshaled when using these between languages.
• Single dimensional arrays of blittable types are also blittable.
Nice post very helpful
ReplyDeleteDBAKings
Output Portal CrackI am very impressed with your post because this post is very beneficial for me and provide a new knowledge to me
ReplyDelete