C# 0 The Complete Reference


IMyIF_A and IMyIF_B



Download 4,07 Mb.
Pdf ko'rish
bet420/1096
Sana23.01.2022
Hajmi4,07 Mb.
#402171
1   ...   416   417   418   419   420   421   422   423   ...   1096
Bog'liq
C-Sharp 3 The Complete Reference Herbert Schildt

IMyIF_A

and


IMyIF_B

. Thus, when 



MyClass

 implements both of these interfaces, it explicitly 

implements each one separately, fully qualifying its name in the process. Since the only way 

that an explicitly implemented method can be called is on an interface reference



MyClass

creates two such references, one for 



IMyIF_A

 and one for 



IMyIF_B

. It then calls two of its 

own methods, which call the interface methods, thereby removing the ambiguity.

Choosing Between an Interface and an Abstract Class

One of the more challenging parts of C# programming is knowing when to create an interface 

and when to use an abstract class in cases in which you want to describe functionality but 

not implementation. The general rule is this: When you can fully describe the concept in 

terms of “what it does” without needing to specify any “how it does it,” then you should 

use an interface. If you need to include some implementation details, then you will need to 

represent your concept in an abstract class.

The .NET Standard Interfaces

The .NET Framework defines a large number of interfaces that a C# program can use. For 

example,

System.IComparable

 defines the 



CompareTo( )

 method, which allows objects to be 

compared when an ordering relationship is required. Interfaces also form an important part 

of the Collections classes, which provide various types of storage (such as stacks and queues) 

for groups of objects. For example, 

System.Collections.ICollection

 defines the functionality 

of a collection. 

System.Collections.IEnumerator

 offers a way to sequence through the 

elements in a collection. These and many other interfaces are described in Part II.

Structures

As you know, classes are reference types. This means that class objects are accessed through 

a reference. This differs from the value types, which are accessed directly. However, sometimes 

it would be useful to be able to access an object directly, in the way that value types are. One 

reason for this is efficiency. Accessing class objects through a reference adds overhead onto 

every access. It also consumes space. For very small objects, this extra space might be 

significant. To address these concerns, C# offers the structure. A 

structure

 is similar to a 

class, but is a value type, rather than a reference type.

Structures are declared using the keyword 



struct

 and are syntactically similar to classes. 

Here is the general form of a 

struct

:

www.freepdf-books.com




Download 4,07 Mb.

Do'stlaringiz bilan baham:
1   ...   416   417   418   419   420   421   422   423   ...   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