I do a lot of technical presentations and those presentations often contain code demos. As a general rule, I favor creating my code demos in advance over typing them in during my presentation. If a demo involves more than a few seconds typing, no one wants to sit and watch the presenter type (or, worse, debug code that he mistyped).
Often I'll have a number of related demos in the same project or the same class. Each demo will be a little more complex or show off a slightly different feature than the prior demo.
In the past, I've added code and commented it out, then commented / uncommented during the presentation. Here is a sample of this technique.
Unfortunately, this method is error-prone. It’s too easy to accidentally uncomment or comment the wrong line or too many lines, causing errors that you will need to debug quickly and with the pressure of an audience staring at you.
But I've found a different simple technique that works very well for Console application demos. I prompt the user to enter a number - then capture the user's input and run the method corresponding with that number. The Console.ReadLine method allows me to capture the user's input and a switch statement allows me to easily translate a number entered into the appropriate method call. A few Console.WriteLine statements clarify what the numbers mean. Below is an example.
This technique allows you to prepare all of your demos in advance, so you don’t need to change anything during your presentation. I like the fact that the technique does not excessively complicate the code you are presenting. Simply focus on the code in one individual case statement at a time.