Студопедия

Главная страница Случайная страница

КАТЕГОРИИ:

АвтомобилиАстрономияБиологияГеографияДом и садДругие языкиДругоеИнформатикаИсторияКультураЛитератураЛогикаМатематикаМедицинаМеталлургияМеханикаОбразованиеОхрана трудаПедагогикаПолитикаПравоПсихологияРелигияРиторикаСоциологияСпортСтроительствоТехнологияТуризмФизикаФилософияФинансыХимияЧерчениеЭкологияЭкономикаЭлектроника






Runtime process.






NET framework classes.

The.NET Framework class library is a library of classes, interfaces, and value types that provide access to system functionality. It is the foundation on which.NET Framework applications, components, and controls are built. The namespaces and namespace categories in the class library are listed in the following table and documented in detail in this reference. The namespaces and categories are listed by usage, with the most frequently used namespaces appearing first.

Perhaps one of the biggest benefits of writing managed code, at least from a developer ’ s point of view, is that you get to use the.NET base class library. The.NET base classes are a massive collection of managed code classes that allow you to do almost any of the tasks that were previously available through the Windows API. These classes follow the same object model that IL uses, based on single inheritance. This means that you can either instantiate objects of whichever.NET base class is appropriate or derive your own classes from them.

The great thing about the.NET base classes is that they have been designed to be very intuitive and easy to use. For example, to start a thread, you call the Start() method of the Thread class. To disable a TextBox, you set the Enabled property of a TextBox object to false. This approach — though familiar to Visual Basic and Java developers, whose respective libraries are just as easy to use — will be a welcome relief to C++ developers, who for years have had to cope with such API functions as GetDIBits(), RegisterWndClassEx(), and IsEqualIID(), as well as a whole plethora of functions that require Windows handles to be passed around

 

 

Describe compilation and execution of.NET programs.

Compiler time process

1. VB.NET, C# and other language compilers generate MSIL code. (In other words, compiling translates your source code into MSIL and generates the required metadata.)

2. Currently " Microsoft Intermediate Language" (MSIL) code is also known as " Intermediate Language" (IL) Code or " Common Intermediate Language" (CIL) Code.SOURCE CODE -.NET COMLIPER--> BYTE CODE (MSIL + META DATA)

Runtime process.

1. The Common Language Runtime (CLR) includes a JIT compiler for converting MSIL to native code.

2. The JIT Compiler in CLR converts the MSIL code into native machine code that is then executed by the OS.

3. During the runtime of a program the " Just in Time" (JIT) compiler of the Common Language Runtime (CLR) uses the Metadata and converts Microsoft Intermediate Language (MSIL) into native code.BYTE CODE (MSIL + META DATA) -- Just-in-Time (JIT) compiler------> NATIVE CODE

 


6. Variables in C#.

You declare variables in C# using the following syntax: datatype identifier; For example: int i; This statement declares an int named i. The compiler won’t actually let you use this variable in an expression until you have initialized it with a value. Variables represent storage locations. Every variable has a type that determines what values can be stored in the variable. C# is a type-safe language, and the C# compiler guarantees that values stored in variables are always of the appropriate type. The value of a variable can be changed through assignment or through use of the ++ and -- operators. C# defines seven categories of variables: static variables, instance variables, array elements, value parameters, reference parameters, output parameters, and local variables. A variable is nothing but a name given to a storage area that our programs can manipulate. Each variable in C# has a specific type, which determines the size and layout of the variable's memory; the range of values that can be stored within that memory; and the set of operations that can be applied to the variable.

Type Example
Integral types sbyte, byte, short, ushort, int, uint, long, ulong and char
Floating point types float and double
Decimal types decimal
Boolean types true or false values, as assigned
Nullable types Nullable data types

C# also allows defining other value types of variable like enum and reference types of variables like class, which we will cover in subsequent chapters. For this chapter, let us study only basic variable types.

 

 

7. Predefined data types in C#.

C# distinguishes between twocategories of data type:

➤ Value types

➤ Reference types

The C# language predefines a set of types that map to types in the common type system. All the predefined types are value types except for object and string. All the predefined types are CLS (common language specification)-compliant except the unsigned integer types and the sbyte type. You can use these types and still be CLS-compliant as long as they are not publicly accessible. If you do need to make one of these types publicly accessible, they can safely map to a CLS-compliant type. So,

Value type: stores its value directly. In memory stored in an area called stack.

Reference type: stores a reference to the value. In memory stores in an area called managed heap.

 

 


Поделиться с друзьями:

mylektsii.su - Мои Лекции - 2015-2024 год. (0.006 сек.)Все материалы представленные на сайте исключительно с целью ознакомления читателями и не преследуют коммерческих целей или нарушение авторских прав Пожаловаться на материал