Академический Документы
Профессиональный Документы
Культура Документы
NET Concepts
Drawbacks of C++
Not platform independent. Code is not protected. It is not multitask. No built in support for threads. Memory management is complicated. Does not provide efficient means for garbage collection Gets complex when u want to develop a graphics rich application in C++.
Benefits of java
Java uses automatic memory allocation and garbage collection Object-oriented approach Java is platform-independent Java is secure Java is multithreaded
Drawbacks of java
Java can be considerably slower Exceptions not caught within a method must be declared as thrown by that method. A worse problem is that the programs do not always work correctly even if they are written correctly, because a Java virtual machine may be written incorrectly.
Conti
Formalized concept of get-set methods, so the code becomes more legible More clean events management (using delegates) Pointers no longer needed
.NET Framework
VB C++ C# JScript J# Common Language Specification Visual Studio.NET Visual Studio.NET ASP.NET Web Forms Web Services ADO.NET and XML Base Class Library Common Language Runtime Operating System
9
Windows Forms
To locate, load, and manage .NET types Automatic memory management, language integration, and type safety Describes all possible data types and programming constructs supported by the runtime A set of rules that defines a subset of types and specifications
10
XML/SOAP
Understanding Assemblies
Assemblies contains CIL code, which is conceptually similar to java bytecode in that it is not compiled to platform specific instruction. C# .NET compiler doesn't generate machine code. It is compiled into "assembly"
13
Assembly
C# source code
Metadata
C# .NET Compiler
IL Assembly
Intermediate Language (IL/CIL): Same as first pass of compiler. It can't be executed (it is not in binary format) Metadata Describes the assembly contents No need for component registry Each assembly includes information about references to other assemblies E.g. If you have a class called Car in a given assembly, the type metadata describes Car's base class, which interfaces are implemented by Car, description of members of Car.
14
Assembly
When CLR loads your application, it examines your program's metadata to know which external assemblies are required for execution Private assemblies Used by single application Is not shared Most preferred method Shared assemblies Intended for multiple applications Global Assembly Cache Manifest The metadata of assemblies: version, list of externally defined assemblies, etc.
15
Example of CIL
CIL sits above a specific compiler (C#, J#, etc.) The associated compiler emits CIL instructions } public class Calc { public int Add(int x, int y) { return x + y; } }
using System; namespace Calculator { public class CalcApp { public static void Main(string[] args) { Calc c = new Calc(); int ans = c.Add(10, 84); Console.WriteLine(ans); Console.ReadLine(); } }
16
17
Manifest
External Assembly
.assembly extern mscorlib { .publickeytoken = (B7 7A 5C 56 19 34 E0 89 ) .ver 1:0:5000:0 } .assembly ConsoleApplication1 { .hash algorithm 0x00008004 .ver 1:0:2058:39833 } .module ConsoleApplication1.exe // MVID: {51BE4F31-CBD0-4AE6-BC9D-F9A4976795FD} .imagebase 0x00400000 .subsystem 0x00000003 .file alignment 4096 .corflags 0x00000001 // Image base: 0x070b0000
// .z\V.4..
18
CIL to Execution
Desktop JIT Server
CIL
Pocket PC
Jitter compiles CIL instructions on the fly into corresponding machine code and cache it. This is useful for not recompiling, if the same method is called again
19
21
Same as C/C++ Derived from a common base class System.ValueType Same as pure abstract class of C++ A description of work that a derived class can perform Similar to a class, but can never be instantiated To group name/value pairs under a specific name Default Storage: System.Int32 (could be changed) Same as C's function pointer (System.MulticastDelegate) Useful for event handling (ASP .NET)
23
C# Type
Byte sbyte short int long ulong float double object string bool
24
(CLS)
Set of guidelines that describe the minimal and complete set of features a given .NET aware compiler must support C# uses + for concatenation whereas VB .NET uses & C# allows operator overloading but VB .NET does not! The void functions may differ in syntax:
' VB .NET // C#
CLR
.NET Namespace
MFC, Java, VB 6.0 have predefined set of classes; C# doesn't C# uses namespace concept Any language targeting the .NET runtime makes use of the same namespaces and same types as C# System is the root namespace
27
Example in C#
System Namespace
using System; public Class MyApp { Console class in public static void Main() System Namespace { Console.WriteLine("Hello World"); } }
28
Example in VB .NET
Imports System Public Module MyApp Sub Main() Console.WriteLine("Hello World") End Sub End Module
29
30
file IO, buffering, etc. GDI+ primitives, bitmaps, fonts, icons, etc. Threads
31
Conclusion
Came up with limitations of previous programming languages Overview of how .NET and C# came up with those limitations Frame work of .NET Explored about CLR and JIT