Book Image

Learn C# in 7 days

By : Gaurav Aroraa
1 (1)
Book Image

Learn C# in 7 days

1 (1)
By: Gaurav Aroraa

Overview of this book

This book takes a unique approach to teach C# to absolute beginners. You’ll learn the basics of the language in seven days. It takes a practical approach to explain the important concepts that build the foundation of the C# programming language. The book begins by teaching you the basic fundamentals using real-world practical examples and gets you acquainted with C# programming. We cover some important features and nuances of the language in a hands-on way, helping you grasp the concepts in a fluid manner. Later, you’ll explore the concepts of Object-Oriented Programming (OOP) through a real-world example. Then we dive into advanced-level concepts such as generics and collections, and you’ll get acquainted with objects and LINQ. Towards the end, you’ll build an application that covers all the concepts explained in the book. By the end of this book, you will have next-level skills and a good knowledge of the fundamentals of C#.
Table of Contents (15 chapters)
Title Page
Credits
About the Author
About the Reviewer
www.PacktPub.com
Customer Feedback
Preface

Collections and non-generics


On day two, we learned about arrays, which are of fixed size, and you can use these for strongly typed list objects. But what about if we want to use or organize these objects into other data structures such as queues, lists, stacks, and so on? All these we can achieve with the use of collections (System.Collections).

There are various ways to play with data (storage and retrieval) with the use of collections. The following are the main collection classes we can use.

Note

System.Collections.NonGeneric (https://www.nuget.org/packages/System.Collections.NonGeneric/ ) is a NuGet package which provides all non-generic types, namely ArrayList, HashTable, Stack, SortedList, Queue, and so on.

ArrayList

As it is an array, it contains an ordered collection of an object and can be indexed individually. As this is a non-generic class, it is available under a separate NuGet package from System.Collections.NonGeneric. To work with the example code, you should first install this...