answersLogoWhite

0


Best Answer

The "switch" statement is a way of performing selection. It allows you to match a value against a known list. In C#:

// code starts

string mood = "happy";

switch (mood)
{
case "sad":
Console.WriteLine("I'm sorry to hear that you are sad.");
break;
case "happy":
Console.WriteLine("I'm glad to hear that you're happy!");
break;
case "angry":
Console.WriteLine("Try to calm down.");
break;
case "excited":
Console.WriteLine("Wow, what are you excited about?!");
break;
}

// code ends

In this example, mood is equal to happy so the code: Console.WriteLine("I'm glad to hear that you're happy!"); will be executed. A switch is essentially an efficient way of writing a lot of IF statements!

User Avatar

Wiki User

14y ago
This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: Show use of switch keywords in small code segment?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Related questions

What tv show had taking it to the street as its theme song?

The AFL Footy Show (Australia) had a segment called, 'Street Talk'. This song was the theme for that segment.


What time does Around the Net After Hours air?

If you're talking about the G4 tv show, Attack of the Show's segment, I'm not sure the exact time of that segment is but the after hours show starts at 1 am EST.


What does this mean About 8330000 results 0.23 seconds?

Hi, I think this is describe Googl search results for a keywords. When you will search any keywords that search engine it will show the resulst and time in seconds


What is the midpoint of the segment below?

There is no segment. You need to click "Add related links" to the left and show an image or something.


How do you show the depth of a line segment?

A line segment has length. That is its only dimension. It does not have any width, or height or depth.


What actors and actresses appeared in Girlesk Show - 1952?

The cast of Girlesk Show - 1952 includes: Tandalaye as Stripper (segment "Slave Dance") Nona Carver as Stripper (segment "Glamazon of the Strip") Beverly Reynard as Stripper (segment "Champagne Sparkle")


Do ads on Google change based on the keywords used to search?

That would depend on who one believes. However, evidence based on different searches would show that advertisements appear to reflect the keywords in the search.


What actors and actresses appeared in Fright Show - 1985?

The cast of Fright Show - 1985 includes: Janet Aspinwall as (segment "Nightfright") Eddie Brill as Eddie Brill John Carl Buechler as (segment "The Thing in the Basement") Marla Carlson as (segment "Illegal Alien") Jeffrey Carter as (segment "Illegal Alien") Dennis Duggan as (segment "Illegal Alien") Gaby Dundon as (segment "Dr. Dobermind") Paul Heckemeyer as (segment "Nightfright") Jennifer Jacobi as Jenny (segment "Dr. Dobermind") Brian Keister as (segment "The Thing in the Basement") Dodsworth Kenyon as (segment "The Thing in the Basement") Jim Lefebvre as (segment "Illegal Alien") Bob Monzani as (segment "Nightfright") Whit Reichert as (segment "The Thing in the Basement") Frank Sheppard as (segment "Illegal Alien") John Stamm as (segment "Illegal Alien") Amanda York as (segment "Nightfright")


What does Google picasa do?

Allows for a person to view, organize, and edit digital images that they may share with others through the use of various keywords. These keywords show up when another person uses the search bar.


On what show was the segment that wonderful year featured?

The Garry Moore show CBS TV 1958-1964


What is a game show segment called?

for knowlege and relation and also enjoy


Show you a line segment that is 2 inches?

--------------- approximately.