The switch Decision Statement - Day 1 - Part 13

Play The switch Decision Statement - Day 1 - Part 13
Sign in to queue


Picking back up on the notion of adding logic to your code, we look at a second decision statement—the switch—and compare its usefulness to the “if” statement we previously looked at.

Download the source code in c#

Download the source code in VB.Net



Download this episode

The Discussion

  • User profile image

    This might not be HUGELY important but your code has an error (in the video and the download).  When you introduced the String.Format you should only have car, boat, cat or "... Sorry we didn't understand your response.  You lose" in your message statement.

    ** Easy fix for someone who is familiar with programming language but to a newbie they might get a wee bit lost.  As the output is not what is expected or originally intended by the programmer.

  • User profile image

    @Nique26: the correct solution would be to replace

    myTextBlock.Text = String.Format("You won a {0}!", message);


    myTextBlock.Text = message;

  • User profile image

    Or, just change message = "You won a new car!";


    message = "new car";

  • User profile image


  • User profile image

    Nope, the code on the video works, is the download that have some bug in it.

    If you copy paste the entire code on a new proyect (and name the textBlock and textBox just like the names on the video) the code works.

Add Your 2 Cents