This print for content only-size & color not accurate 7" X 9-1/4" / casebound / malloy


' A VB "Module" is a class that contains only



Download 21,46 Mb.
Pdf ko'rish
bet84/1830
Sana28.09.2021
Hajmi21,46 Mb.
#188411
1   ...   80   81   82   83   84   85   86   87   ...   1830
Bog'liq
[book] [en] Pro C# 2008 and the NET 3.5 Platform Fourth Edition

' A VB "Module" is a class that contains only

' static members.

Module Program

Sub Main()

Dim c As New Calc

Dim ans As Integer = c.Add(10, 84)

Console.WriteLine("10 + 84 is {0}.", ans)

Console.ReadLine()

End Sub


End Module

Class Calc

Public Function Add(ByVal x As Integer, ByVal y As Integer) As Integer

Return x + y

End Function

End Class

End Namespace

If you examine the CIL for the Add() method, you find similar instructions (slightly tweaked by

the VB .NET compiler, vbc.exe):

.method public instance int32  Add(int32 x,

int32 y) cil managed

{

// Code size       8 (0x8)



.maxstack  2

.locals init (int32 V_0)

IL_0000:  ldarg.1

IL_0001:  ldarg.2

IL_0002:  add.ovf

IL_0003:  stloc.0

IL_0004:  br.s       IL_0006

IL_0006:  ldloc.0

IL_0007:  ret

} // end of method Calc::Add





Source Code

The 


Calc.cs

and 


Calc.vb

code files are included under the Chapter 1 subdirectory.

C H A P T E R   1  

T H E   P H I L O S O P H Y   O F   . N E T



14

8849CH01.qxd  10/1/07  10:30 AM  Page 14




Benefits of CIL

At this point, you might be wondering exactly what is gained by compiling source code into CIL

rather than directly to a specific instruction set. One benefit is language integration. As you have

already seen, each .NET-aware compiler produces nearly identical CIL instructions. Therefore, all

languages are able to interact within a well-defined binary arena.

Furthermore, given that CIL is platform-agnostic, the .NET Framework itself is platform-

agnostic, providing the same benefits Java developers have grown accustomed to (i.e., a single code

base running on numerous operating systems). In fact, there is an international standard for the

C# language, and a large subset of the .NET platform and implementations already exist for many

non-Windows operating systems (more details in the section “The Platform-Independent Nature

of .NET” toward the end of this chapter). In contrast to Java, however, .NET allows you to build

applications using your language of choice.

Compiling CIL to Platform-Specific Instructions

Due to the fact that assemblies contain CIL instructions, rather than platform-specific instructions,

CIL code must be compiled on the fly before use. The entity that compiles CIL code into meaningful

CPU instructions is termed a 



just-in-time (JITcompiler, which sometimes goes by the friendly

name of 


Jitter. The .NET runtime environment leverages a JIT compiler for each CPU targeting the

runtime, each optimized for the underlying platform.

For example, if you are building a .NET application that is to be deployed to a handheld device

(such as a Pocket PC), the corresponding Jitter is well equipped to run within a low-memory envi-

ronment. On the other hand, if you are deploying your assembly to a back-end server (where

memory is seldom an issue), the Jitter will be optimized to function in a high-memory environ-

ment. In this way, developers can write a single body of code that can be efficiently JIT-compiled

and executed on machines with different architectures.

Furthermore, as a given Jitter compiles CIL instructions into corresponding machine code, it

will cache the results in memory in a manner suited to the target operating system. In this way, if a

call is made to a method named PrintDocument(), the CIL instructions are compiled into platform-

specific instructions on the first invocation and retained in memory for later use. Therefore, the

next time PrintDocument() is called, there is no need to recompile the CIL.


Download 21,46 Mb.

Do'stlaringiz bilan baham:
1   ...   80   81   82   83   84   85   86   87   ...   1830




Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©hozir.org 2024
ma'muriyatiga murojaat qiling

kiriting | ro'yxatdan o'tish
    Bosh sahifa
юртда тантана
Боғда битган
Бугун юртда
Эшитганлар жилманглар
Эшитмадим деманглар
битган бодомлар
Yangiariq tumani
qitish marakazi
Raqamli texnologiyalar
ilishida muhokamadan
tasdiqqa tavsiya
tavsiya etilgan
iqtisodiyot kafedrasi
steiermarkischen landesregierung
asarlaringizni yuboring
o'zingizning asarlaringizni
Iltimos faqat
faqat o'zingizning
steierm rkischen
landesregierung fachabteilung
rkischen landesregierung
hamshira loyihasi
loyihasi mavsum
faolyatining oqibatlari
asosiy adabiyotlar
fakulteti ahborot
ahborot havfsizligi
havfsizligi kafedrasi
fanidan bo’yicha
fakulteti iqtisodiyot
boshqaruv fakulteti
chiqarishda boshqaruv
ishlab chiqarishda
iqtisodiyot fakultet
multiservis tarmoqlari
fanidan asosiy
Uzbek fanidan
mavzulari potok
asosidagi multiservis
'aliyyil a'ziym
billahil 'aliyyil
illaa billahil
quvvata illaa
falah' deganida
Kompyuter savodxonligi
bo’yicha mustaqil
'alal falah'
Hayya 'alal
'alas soloh
Hayya 'alas
mavsum boyicha


yuklab olish