Sunteți pe pagina 1din 3

.

NET
Is the name Microsoft gives to its general vision of the future of computing. The view being of a world in which many applications run in a distributed manner across the Internet.

Just A Little C#
What Your Mother never Told You About .NET

Development end of the .NET


.NET Framework
Common Language Runtime .NET Framework Classes ASP.NET (the next generation of Active Server Pages technologies) WinForms for for developing desktop applications.

Common Language Runtime (CLR)


Is the virtual machine component of Microsoft's .NET initiative. It is Microsoft's implementation of the Common Language Infrastructure (CLI) standard, which defines an execution environment for program code. The CLR runs a form of bytecode called the Common Intermediate Language (CIL, previously known as MSIL -- Microsoft Intermediate Language).

Common Language Runtime (CLR)


Developers using the CLR write code in a language such as C# or VB.Net. At compile-time, a .NET compiler converts such code into CIL code. At runtime, the CLR's just-in-time compiler (JIT compiler) converts the CIL code into code native to the operating system. Alternatively, the CIL code can be compiled to native code in a separate step prior to runtime.

C# versus Java
C# contains more primitive data types than Java. Unlike Java, C# can overload various operators. Like Java, C# gives up on the idea of multiple class inheritance. C# code does not require header files (as does C++).

C# versus C++
C# is about letting go of precise control, and letting the framework help you focus on the big picture. With the managed environment of .NET, you give up that level of control. You no longer control the lifetime of your object. C# has no destructor.

C# Reference and Value Types


C# distinguishes between value types and reference types. Simple types (int, long, double, and so on) and structs are value types, while all classes are reference types, as are Objects. Value types hold their value on the stack, like variables in C++, unless they are embedded within a reference type.

C# versus C++
Reference type variables sit on the stack, but they hold the address of an object on the heap, much like pointers in C++. Value types are passed to methods by value (a copy is made), while reference types are effectively passed by reference.

Everything Derives from Object


In C# everything ultimately derives from Object. This includes classes you create, as well as value types such as int or structs. The Object class offers useful methods, such as ToString. An example of when you use ToString is with the System.Console.WriteLine method, which is the C# equivalent of cout. The method is overloaded to take a string and an array of objects.

C# Pointers
In C#, pointers can only be declared to hold the memory addresses of value types (except in the case of arrays). Pointers are declared implicitly, using the 'dereferencer' symbol *, as in the following example:
int *p;

C# Pointers
*p can appear in integer assignments like the following:
*p = 5;

Unsafe Code
A major problem with using pointers in C# is that C# operates a background garbage collection process. In freeing up memory, this garbage collection is liable to change the memory location of a current object without warning.

Unsafe Code
To address the problem of garbage collection, one can declare a pointer within a 'fixed' expression. This 'pins' the location of the type pointed to - the memory location of the type therefore remains static, safe from garbage collection. Note that the fixed statement can only be used within the context of unsafe code.

Unsafe Code

Reference
http://www.softsteel.co.uk/tutorials/cSharp/ cIndex.html

S-ar putea să vă placă și