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



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

Introducing the C# Class Type

As far as the .NET platform is concerned, the most fundamental programming construct is the class



type. Formally, a class is a user-defined type that is composed of field data (often called member

variables) and members that operate on this data (such as constructors, properties, methods,

events, and so forth). Collectively, the set of field data represents the “state” of a class instance (oth-

erwise known as an 

object). The power of object-based languages such as C# is that by grouping

data and related functionality in a class definition, you are able to model your software after entities

in the real world.

To get the ball rolling, create a new C# Console Application named SimpleClassExample. Next,

insert a new class file (named Car.cs) into your project using the Project ➤ Add Class menu selec-

tion, choose the Class icon from the resulting dialog box as shown in Figure 5-1, and click the Add

button.

A class is defined in C# using the class keyword. Here is the simplest possible declaration:

class Car

{

}



Once you have defined a class type, you will need to consider the set of member variables that

will be used to represent its state. For example, you may decide that cars maintain an int data type

to represent the current speed and a string data type to represent the car’s friendly pet name. Given

these initial design notes, update your Car class as follows:

class Car

{


Download 21,46 Mb.

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