O'Reilly logo

C# Data Structures and Algorithms by Marcin Jamro

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Example – game map

Another example of the application of a two-dimensional array is a program that presents a map of a game. The map is a rectangle with 11 rows and 10 columns. Each element of the array specifies a type of terrain as grass, sand, water, or wall. Each place on the map should be shown in a particular color (such as green for grass), as well as using a custom character that depicts the terrain type (such as for water), as shown in the screenshot:

At the start, let's declare the enumeration value, named TerrainEnum, with four constants, namely GRASS, SAND, WATER, and WALL, as follows:

public enum TerrainEnum { GRASS, SAND, WATER, ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required