Chapter 2. Introduction to C#

IN BRIEF

In this chapter, you will be introduced to various aspects of the .NET Framework, including data types, the Common Language Runtime, and garbage collection. The goal of this chapter is to give you a basic understanding of the .NET Framework, how it works, and how C# is an integral part of that framework. You don't have to have any previous exposure to C# to read this book. Some background and experience with programming in general would be helpful, but is also not necessary.

WHAT YOU NEED

RECOMMENDED SOFTWARE.NET Framework Visual Studio .NET
RECOMMENDED HARDWARE.NET-enabled desktop client
SKILLS REQUIREDBasic programming skills

INTRODUCTION TO C# AT A GLANCE

Why Learn Yet Another Language?37  
Learning Common Types38  
 Understanding Value Types38Reference Versus Value Types40
 Understanding Reference Types39  
What Is the Common Language Runtime? 40  
 Multiple Languages, One Runtime42The JIT Compiler43
 Isolation42Code Execution43
 Platform Invoke42COM Interoperability43
 Code Access Security42Rotor: Microsoft's Shared Source Common Language Infrastructure44
Take Out the Trash: Theory of Garbage Collection44  
 Reference Counting44Partial Collection45
 Generations44Nondeterministic Finalization45
 Collection45Using IDisposable to Create Well-Behaved Objects46
Introduction to the Base Class Library 48  
The Canonical “Hello World” Example49  

Welcome to the .NET Framework. One of the main goals of the .NET Framework is to provide a universal, safe type system through which any language can communicate with managed code written in any other language. By defining a common set of data types, such as int, char, string, and the like, it also provides the ability for an object written in one language to be used and accessed in another language. As a result of the .NET Framework effort, C# was developed to harness the power of the platform. In addition, C# represents an evolution in language design.

C# features many object-oriented features, such as properties for data encapsulation, polymorphic behavior, inheritance, and interface implementation. In addition, C# allows for a developer to tap into unsafe code (discussed later) when performance is at a premium. C# was developed to provide the best aspects of C++, Java, SmallTalk, and Modula2. Elements from each of the languages can be seen in C# and in the Common Language Runtime itself.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.138.169.40