It's dangerous to code alone! Take this.

Solutions - 5th Edition

This page contains the solutions for the challenges contained in The C# Player’s Guide, 5th Edition.

These are here to help you if you get stuck on one of the challenges, and also to give you a chance to compare your answer against somebody else’s.

There is always more than one way to solve a problem. Just because your version and mine are different does not mean yours is wrong.

Note: I’m interested in also posting others’ answers to these challenges to give people alternative perspectives. If you want to share your solutions with others, let me know! (I’d love to have solutions from other veteran C# programmers, as well as other veteran programmers new to C#, and also people brand new to programming, to get various perspectives.)

If you discover any problems or bugs in the sample code provided here, please report it so I can fix it.

Some Helpful Downloads

Level Title
1 Knowledge Check - C#
2 Installing Visual Studio
3 Hello World!
3 What Comes Next
3 The Makings of a Programmer
3 Consolas and Telim
4 The Thing Namer 3000
5 Knowledge Check - Variables
6 The Variable Shop
6 The Variable Shop Returns
6 Knowledge Check - Type System
7 The Triangle Farmer
7 The Four Sisters and the Duckbear
7 The Dominion of Kings
8 The Defense of Consolas
9 Repairing the Clocktower
9 The Watchtower
10 Buying Inventory
10 Discounted Inventory
11 The Prototype
11 The Magic Cannon
12 The Replicator of D’To
12 The Laws of Freach
13 Taking a Number
13 Countdown
14 Knowledge Check - Memory
14 Hunting the Manticore
15 Knowledge Check - Objects
16 Simula’s Test
17 Simula’s Soup
18 Vin Fletcher’s Arrows
19 Vin’s Trouble
20 The Properties of Arrows
21 Arrow Factories
24 The Point
24 The Color
24 The Card
24 The Locked Door
24 The Password Validator
24 Rock-Paper-Scissors
24 15-Puzzle
24 Hangman
24 Tic-Tac-Toe
25 Packing Inventory
26 Labeling Inventory
26 The Old Robot
27 Robotic Interface
28 Room Coordinates
29 War Preparations
30 Colored Items
31 The Fountain of Objects
31 Small, Medium, or Large
31 Pits
31 Maelstroms
31 Amaroks
31 Getting Armed
31 Getting Help
31 The Fountain of Objects - Combined
32 The Robot Pilot
32 Time in the Cavern
32 Lists of Commands
33 Knowledge Check - Large Programs
33 The Feud
33 Dueling Traditions
34 Safer Number Crunching
34 Knowledge Check - Methods
34 Better Random
35 Excepti’s Game
36 The Sieve
37 Knowledge Check - Events
37 Charberry Trees
38 Knowledge Check - Lambdas
38 The Lambda Sieve
39 The Long Game
40 The Potion Masters of Pattren
41 Knowledge Check - Operators
41 Navigating Operand City
41 Indexing Operand City
41 Converting Directions to Offsets
42 Knowledge Check - Queries
42 The Three Lenses
43 The Repeating Stream
44 Knowledge Check - Async
44 Asynchronous Random Words
44 Many Random Words
45 Uniter of Adds
45 The Robot Factory
46 Knowledge Check - Unsafe Code
47 Knowledge Check - Other Features
48 Colored Console
48 The Great Humanizer
49 Knowledge Check - Compiling
50 Knowledge Check - .NET
51 The Altar of Publication
52 Building Character
52 The True Programmer
52 Characters, Actions, and Players
52 Attacks
52 Damage and HP
52 Death
52 Battle Series
52 The Uncoded One
52 The Player Decides
52 The Game’s Status
52 Items
52 Gear
52 Stolen Inventory
52 Vin Fletcher
52 Attack Modifiers
52 Damage Types
52 Making It Your Own
52 Restoring Balance
A Knowledge Check - Visual Studio
B Knowledge Check - Compiler Errors
C Knowledge Check - Debugging