using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Ch04Ex03
{
class Program
{
static void Main(string[] args)
{ const string myName = "karli";
const string sexyName ="angelina";
const string sillyName = "ploppy";
string name;
Console.WriteLine ("What is your name?");
name = Console.ReadLine ();
switch (name.ToLower())
{case myName:
Console.WriteLine ("You have the same name as me!");
break;
case sexyName:
Console.WriteLine ("My, what a very sexy name! [o_o]");
break;
case sillyName:
Console.WriteLine ("My, what a rather silly name you have! (wtf is this person thinking rofl)");
break;
}
Console.WriteLine ("Hello {0} !", name);
Console.ReadKey ();
}
}
}
A very innovative branching and conditional logic method in C#.
A bit tricky to implement in all situations, but very useful and concise.
The switch statement apparently makes code more readable by preventing the use of "ultra-nested" code (super indented) that would be generated if
soloing a program with if and else statements alone.