C# and .NET .NET Architecture Compiling and running code that targets .NET Advantages of Microsoft Intermediate Language (MSIL) Value and Reference Types Data Typing Understanding error handling and attributes Assemblies, .NET base classes, and namespaces The Relationship of C# to .NET C# is always used within the .NET Framework, hence: 1. The architecture and methodologies of C# reflect the underlying methodologies of .NET 2. In many cases, specific language features of C# depend on features of .NET or the .NET base classes. Because of this dependence: Understanding of he architecture and methodology of .NET is required prior to C# programming. C# Programming 1. Specifically designed for .NET 2. Language is based on present day understanding of design methodologies and Object oriented Principles 3. Must understand .NET framework in order to develop applications in C# effectively. The Common Language Runtime CLR (Common Language Runtime) is central to understanding C# Commonly CLR is often termed managed code. Compilation of C# (and many other languages) occurs in two steps: 1. Compilation of source code to so called Intermediate Langue (IL) 2. Compilation of IL to platform-specific code by CLR. Support for Object Orientation and Interfaces .NET implementation has practical limitations IL (Intermediate Language) uses a single implementation inheritance of classes. Working with .NET implies compiling to IL This in turn means usage of object oriented-programming methodologies Object Oriented Programming is not sufficient to give you interoperability (e.g., C++ and Java are not interoperable in spite of using the same object oriented programing paradigm). Language Interoperability So what is exactly language interoperability? Initially through COM used to interface various modules of different languages allowing them to communicate with each other, and/or instantiate each others modules, In no way did COM components written in different languages directly communicate with each other, and/or Instantiate each others modules => this was done only through COM intermediation. In addition COM architecture did not permit implementation inheritance => loss of many Object Oriented Programming features Debugging requires each component to be debugged independently, It was not possible to step between languages in the debugger, Language Interoperability means that classes written in one language were able to directly invoke classes written in another language. This was achieved in .NET with IL! Distinct Value and Reference Types Strong Distinction between: Value: variables directly stores its data, Typically stored on the “stack,” and Reference: variables that store the address at which the corresponding data can be found Located in are of memory know as “managed heap” Strong Data Typing IL is based on “Exceptionally Strong Data Typing”. Gaines afforded by of enforcing this feature outweighs the performance losses: Language Interoperability Garbage Collection Security Application Domains: Designed to ease the overhead involved when Running application that need to be isolated from each other, but Need to communicate with each other.