Chapter 9: Creating Value Types with Enumerations and Structs


Chapter 9

Creating Value Types with Enumerations and Structs

After completing this chapter, you will be able to:

  • Declare an enumeration type.

  • Create and use an enumeration type.

  • Declare a structure type.

  • Create and use a structure type.

In Chapter 8, “Understanding Values and References,” you learned about the two fundamental kinds of types that exist in Microsoft Visual C#: value types and reference types. A value type variable holds its value directly on the stack, whereas a reference type variable holds a reference to an object on the heap. In Chapter 7, “Creating and Managing Classes and Objects,” you learned how to write your own classes, thus creating your own reference types. In this chapter, you'll learn how to write your own value types.

C# supports two kinds of value types: enumerations and structures.




Microsoft Visual C# 2005 Step by Step
Microsoft® Visual C#® 2005 Step by Step (Step By Step (Microsoft))
ISBN: B002CKYPPM
EAN: N/A
Year: 2005
Pages: 183
Authors: John Sharp

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net