56Microsoft Visual Studio 2010: A Beginner’s Guide
Listing 2-3 An example of an enum
C#:
public enum BankAccount
{
Checking,
Saving, Loan
}
VB:
Enum BankAccount
Checking
Saving
Loan
End Enum
Listing 2-4 shows how you can use the BankAccount enum:
Listing 2-4 Using an enum
C#:
BankAccount accountType = BankAccount.Checking;
string message =
accountType == BankAccount.Checking ? "Bank Account is Checking" : "Bank Account is Saving";
VB:
Dim accountType As BankAccount = BankAccount.Checking
Dim message =
IIf(accountType = BankAccount.Checking, "Bank Account is Checking",
"Bank Account is Saving")