C# 0 The Complete Reference


int  arguments. The other takes  double



Download 4,07 Mb.
Pdf ko'rish
bet586/1096
Sana23.01.2022
Hajmi4,07 Mb.
#402171
1   ...   582   583   584   585   586   587   588   589   ...   1096
Bog'liq
C-Sharp 3 The Complete Reference Herbert Schildt

int

 arguments. The other takes 



double

arguments.

Let’s look at this program closely. First, notice that 

MyClass

 defines a public constructor 

and a number of public methods, including the overloaded 

Set( )

 method.


Inside

Main( )

, a 


Type

 object representing 



MyClass

 is obtained using this line of code:

Type t = typeof(MyClass); // get a Type object representing MyClass

Recall that 



typeof

 returns a 



Type

 object that represents the specified type, which in this case 

is

MyClass

.

Using



t

 and the Reflection API, the program then displays information about the methods 

supported by 

MyClass

. First, a list of the methods is obtained by the following statement:

MethodInfo[] mi = t.GetMethods();

Next, a 


foreach

 loop is established that cycles through 



mi

. With each pass, the return 

type, name, and parameters for each method are displayed by the following code:

// Display return type and name.

Console.Write("   " + m.ReturnType.Name +

              " " + m.Name + "(");

www.freepdf-books.com



468

 

P a r t   I :  



T h e   C #   L a n g u a g e

// Display parameters.

ParameterInfo[] pi = m.GetParameters();

for(int i=0; i < pi.Length; i++) {

  Console.Write(pi[i].ParameterType.Name +

                " " + pi[i].Name);

  if(i+1 < pi.Length) Console.Write(", ");

}

In this sequence, the parameters associated with each method are obtained by calling 




Download 4,07 Mb.

Do'stlaringiz bilan baham:
1   ...   582   583   584   585   586   587   588   589   ...   1096




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