5 C# Collections & Iterators

 

This chapter covers

  • Using Array in C#
  • Working with Collections
  • Making use of the shared System.Linq namespace
  • Improving our code with loops and iteration
  • Developing a Tic Tac Toe minigame

With this fifth chapter, we finally reached the end of the introductory portion of this manuscript. Until now, we learned everything about C# as a utility, medium, and tool. From the technology stack behind to the individual components that make this language. We learned programming basics and built a project on each step throughout our journey.

With this final step, we will get comfortable with the last programming basics essential to any application and set up the most extensive and feature-richest project so far.

In this chapter, we will create an application famous for its seemingly simple appearance but surprisingly complicated code, the well-known Tic-Tac-Toe minigame.

This project entails the need to master much more than what we worked on until now. This time, apart from variables, conditionals, console methods, and operators, we also need to step towards arrays, collections, and iterators. Even a simple AI is needed not to obligate the user to include a second player.

As we can see, this fifth project will be the first to encompass everything introductory a programming language has to offer, aiding us to master the language by itself before we embark on this book's advanced sections.

For we say without further delay, let us start chapter five of this book.

5.1 Arrays in C#

5.1.1 The definition of an array

5.1.2 Declaring arrays

5.1.3 Types of arrays

5.1.4 Array properties and methods

5.2 Collections in C#

5.2.1 The definition of a collection

5.2.2 System.Collections classes

5.2.3 System.Collections.Concurrent classes

5.2.4 System.Collections.Generic classes

5.2.5 Collection properties and methods

5.2.6 Differences between array and collection

5.2.7 The shared System.Linq namespace

5.3 Iteration statements in C#

5.3.1 Loops and Iterators

5.3.2 Types of Iterators and loops in C#

5.4 Tic-Tac-Toe

5.4.1 The Project