What’s in This Chapter
Wrox.com Downloads for This Chapter
Please note that all the code examples for this chapter are available as a part of this chapter’s code download on the book’s website at www.wrox.com/go/csharp5programmersref on the Download Code tab.
A variable holds a single value. It may be a simple value, such as an
string, or a reference to a more complex entity such as a class or structure.
Classes and structures are both container types. They group related data values and methods into a convenient package that you can manipulate as a group.
For example, a
Recipe class would contain fields or properties holding information about a recipe such as ingredients, temperature, instructions, and number of servings. It could also include methods to convert measurements between English and metric, to scale the recipe for different numbers of servings, and to print the recipe.
If you make an instance of the
Recipe class and fill it with the data for a particular recipe, you can move the object around as a single unit instead of passing around separate variables holding the ingredients, temperature, instructions, and number of servings. The object also contains methods for manipulating the recipe, so you don’t need to write a separate module ...