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


// If the value from GetIntFromDatabase() is null



Download 21,46 Mb.
Pdf ko'rish
bet306/1830
Sana28.09.2021
Hajmi21,46 Mb.
#188411
1   ...   302   303   304   305   306   307   308   309   ...   1830
Bog'liq
[book] [en] Pro C# 2008 and the NET 3.5 Platform Fourth Edition

// If the value from GetIntFromDatabase() is null,

C H A P T E R   4  



C O R E   C #   P R O G R A M M I N G   C O N S T R U C T S, PA RT   I I



138

8849CH04.qxd  10/1/07  10:31 AM  Page 138




// assign local variable to 100.

int? myData = dr.GetIntFromDatabase() ?? 100;

Console.WriteLine("Value of myData: {0}", myData.Value);

Console.ReadLine();

}



Source Code

The NullableTypes application is located under the Chapter 4 subdirectory.



Summary

This chapter began with an examination of several C# keywords that allow you to build custom

methods. Recall that by default, parameters are passed by value; however, you may pass a para-

meter by reference if you mark it with ref. or out. You also learned about the role of optional

parameters and how to define and invoke methods taking parameter arrays.

Once we investigated the topic of method overloading, the bulk of this chapter examined sev-

eral details regarding how arrays, enumerations, and structures are defined in C# and represented

within the .NET base class libraries. Along the way, you examined several details regarding value

types and reference types, including how they respond when passing them as parameters to meth-

ods, and how to interact with nullable data types using the ? and ?? operators. With this, our initial

investigation of the C# programming language is complete! In the next chapter, we will begin to dig

into the details of object-oriented development.

C H A P T E R   4  

C O R E   C #   P R O G R A M M I N G   C O N S T R U C T S, PA RT   I I



139

8849CH04.qxd  10/1/07  10:31 AM  Page 139




8849CH04.qxd  10/1/07  10:31 AM  Page 140


Defining Encapsulated Class Types

I

n the previous two chapters, you investigated a number of core syntactical constructs that are

commonplace to any .NET application you may be developing. Here, you will begin your examina-

tion of the object-oriented capabilities of C#. The first order of business is to examine the process of

building well-defined class types that support any number of constructors. Once you understand

the basics of defining classes and allocating objects, the remainder of this chapter will examine the

role of 

encapsulation. Along the way you will understand how to define class properties as well as

the role of static fields and members, read-only fields, and constant data. We wrap up by examining

the role of XML code documentation syntax.


Download 21,46 Mb.

Do'stlaringiz bilan baham:
1   ...   302   303   304   305   306   307   308   309   ...   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