Introduction

   


In Chapter 3, "A Guided Tour through C#: Part I," Chapter 4, "A Guided Tour through C#: II," and Chapter 5, "Your First Object-Oriented Program," you met two of the predefined types in C#, int and string. You saw how it was possible to specify whether a variable was meant to hold whole numbers, by declaring it to be of type int, or to represent text, by declaring it to be of type string.

In the simple elevator simulation program, you were shown how to define and use your own custom-made, types such as the Elevator and Person classes. In particular, you encountered the possibility of combining the following ingredients to construct the Elevator class.

  • Two of the predefined types in C#, int and string

  • The pre-fabricated types from .NET's class library (Console and Math classes)

  • Your own custom-made Person type

This idea of combining and extending different types by using them as building blocks to form new types is a core concept and a major strength of object-oriented programming. To make you a better object-oriented programmer, you need a proficient understanding of the predefined building blocks found in C#.

The predefined types of C# can conveniently, albeit artificially, be divided into two major groups simple types and derived types:

  • Simple types A pivotal set of building blocks is found in C#'s set of simple types, of which int is just one example. Simple types allow you to work with numbers and single characters in your source code. They provide you with the basis to represent information, such as the speed of an airplane in an aviation simulation or calculating the movement of an animated spaceship. C# provides a broad range of simple types (13 to be exact) that allow you to match each piece of information with a suitable type.

  • Derived predefined types string is an example of a pre-defined type and represents a more complex variety of types, often with elaborate functionality.

This chapter thoroughly discusses the comprehensive set of simple types used to represent single numbers and also introduces the simple type bool, which allows you to represent the states true and false.


   


C# Primer Plus
C Primer Plus (5th Edition)
ISBN: 0672326965
EAN: 2147483647
Year: 2000
Pages: 286
Authors: Stephen Prata

Similar book on Amazon

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