C# Basics: switch control statement
| Published on 6/8/2009 by Dotnetindex More articles in .NET
|
We will look up Switch statement in C#. Switch statement is another control statement that handles multiple selections and enumerations. It could be replace with IF statement.
int fruit = "Apple";
switch (fruit )
{
case "Orange":
Console.WriteLine("Nothing done");
break;
case "Banana":
Console.WriteLine("Nothing done");
break;
case "Apple":
Console.WriteLine("This must be written on shell");
break;
default:
Console.WriteLine("Nothing done but it\'s the default case");
break;
}
As you've seen example, Switch control looks for the match. If you have not change anything, when you run this script, you must see "This must be written on shell" on console. Change now fruit as "AppleX". The default case will be run and default statement will be seen on shell. |
no comments submitted
Latest Posts
- ADO.NET Data Services business logic processing
- Using the MSChart ActiveX Control with VB.NET
- XAML Organizer is a Visual Studio 2008 add-in for organizing
- Shows how to use the new BlockingCollection class in C# 4.0
- Using a ListView with Grouping to create a WPF Report Engine
- A WPF and Silverlight Framework to Animate Pages like Powerpoint Slides
- How to create conditional If / Else logic in a BizTalk map.
- An iterator is a section of code that returns an ordered sequence of values of the same type.
- How to use the managed IIS UrlRewrite Module with a custom SQL Server Lookup provider
- how to build a simple database application using WPF
- A review of the latest version of Crypto Obfuscator for .NET and its features.
- Create A Custom FindControl for Flow Documents
- Effective C# Second Edition Book Review
- An open source WPF report engine that gets benefits from the current WPF controls,
- Use Biztalk 2006r2 SMTP adapter within orchestration
- Join Lists with LINQ - SharePoint 2010



