Maximizing.ASP.dot.NET.Real.World.ObjectOriented.Development [Electronic resources] نسخه متنی

اینجــــا یک کتابخانه دیجیتالی است

با بیش از 100000 منبع الکترونیکی رایگان به زبان فارسی ، عربی و انگلیسی

Maximizing.ASP.dot.NET.Real.World.ObjectOriented.Development [Electronic resources] - نسخه متنی

Jeffrey Putz

| نمايش فراداده ، افزودن یک نقد و بررسی
افزودن به کتابخانه شخصی
ارسال به دوستان
جستجو در متن کتاب
بیشتر
تنظیمات قلم

فونت

اندازه قلم

+ - پیش فرض

حالت نمایش

روز نیمروز شب
جستجو در لغت نامه
بیشتر
لیست موضوعات
توضیحات
افزودن یادداشت جدید






Enumerations


Back in the old days of computer mainframes, values were stored with alphanumeric codes that, without some kind of documentation, didn't mean much of anything to anyone but the person who programmed them. For example, an insurance company might rate a car with the code "CC." Any idea what that means? I don't know either.

Enumerations make it easier to specify a value that you can spot and understand. In our auto insurance example, CarType.CompactCar is a lot easier to understand than "CC." Listing 2.18 shows how we declare an enumeration.

Listing 2.18. A sample enumeration for car types

C#


enum CarType
{
CompactCar,
Truck,
SportsCar,
Suv
}

VB.NET


Enum CarType
CompactCar
Truck
SportsCar
Suv
End Enum

Let's apply this concept to something you've probably used before. Every SqlConnection object has a State property that returns a ConnectionState value. Among the more popular values for this property are ConnectionState.Open and ConnectionState.Closed. Beats the heck out of a number or alphanumeric code!

You can also specify numeric values for your enumeration values, but they are optional.


/ 146