C# – Is the StringBuilder class really more efficient? (Demo)



C# – Is the StringBuilder class really more efficient? (Demo)

C# - Is the StringBuilder class really more efficient? (Demo)

This is a companion video for Rogue C# – a free, ongoing C# tutorial from ComeauSoftware.com. For the introduction, go to:
https://www.comeausoftware.com/c-sharp/new-tutorial-series-rogue-csharp/

You can also go directly to the chapter this video was made to accompany.
https://www.comeausoftware.com/c-sharp/displaying-the-game-map/

In this course, we’re learning C# by developing a rougelike RPG closely based on the original Rogue. The graphics are intentionally very simple, using ASCII characters to construct the map in a Windows Forms application. This keeps the focus on the language itself.

In this video, we look at the difference between manual string concatenation and use of the StringBuilder. The array that holds the map contents contains 2000 elements, each containing a MapSpace object with the information for that space. The function for displaying the map takes the display character from each one and concatenates it into one string. This is a great example of when to use StringBuilder.

If you liked this video, please take a moment to Like and Subscribe for notifications of future videos.

Music:
Gitarrenspiel by Dieter Robbins