Free Programming E-Books
Free download ebooks on computer and programming | |||
Free ebook "Beginning C# Objects: From Concepts to Code" Sample Chapters
Beginning C# Objects: From....
Download chapter
Free Download Chapter 3: Objects and Classes
Beginning C# Objects: From....
Download chapter
Free Download Chapter 6: Collections of Objects Beginning C# Objects: From Concepts to Code is a comprehensive yet approachable guide for anyone interested in learning the C# language, beginning with the basics. To begin, this book addresses the two fundamental concepts that programmers must grasp in order to write a professional object-oriented C# application: the nature and characteristics of objects, and the structure that allows you to take best advantage of C#'s object-oriented makeup. In addition to the basics of C# syntax, this book introduces object terminology-teaching you how to think in terms of objects-and provides an introduction of object modeling, illustrating how to translate an object model into C# code with ease. For folks who have already attempted to learn C# but are still having trouble mastering C#'s object-oriented nature, the case study format of this book will be invaluable in showing you how to translate a UML model into a fully-functional C# application. An overwhelming number of programmers are now moving to C# as their language of choice for developing powerful, maintainable, scalabe software applications. Whether you're learning C# as your first programming language, moving to C# from a non-object-oriented language, or have previously programmed with C# but still feel unsure when it comes to object aspects, this book is a perfect fit for you. Collections of ObjectsYOU LEARNED ABOUT the process of creating objects based on class definitions, a process known as instantiation, in Chapter 3. When we're only creating a few objects, we can afford to declare individualized reference variables for these objects: Students s1, s2, s3, perhaps, or Professors profA, profB, profC. But, at other times, individualized reference variables are impractical.
Fortunately, OOPLs solve this problem by providing a special category of object called a collection that is used to hold and organize other objects. In this chapter, you'll learn about
What Are Collections?We'd like a way to gather up objects as they are created so that we can manage them as a group and operate on them collectively, along with referring to them individually when necessary. For example:
We use a special type of object called a collection to group other objects. A collection object can hold/contain multiple references to some other type of object. Think of a collection like an egg carton, and the objects it holds like the eggs! Both are objects, but with decidedly different properties. Because collections are implemented as objects, this implies that
Collections Must Be Instantiated Before They Can First Be UsedWe can't merely declare a collection: ArrayList is one of C#'s predefined collection types, defined by the .NET Framework Class Library (FCL).We'll introduce the ArrayList class in this chapter, and we'll then go into greater detail about ArrayLists, along with several other collection types, in Chapter 13. We have to take the distinct step of using the new operator to actually create an empty CollectionType object in memory, as follows:
c = new CollectionType(); | |||