Wrox Home  
Search P2P Archive for: Go

  Return to Index  

aspx_beginners thread: Switch statement rules


Message #1 by "Frode" <fstroemm@o...> on Sun, 13 Oct 2002 16:38:30
Beginning asp.net 1.0 with C#  explains this on page 228:

switch (Confirmation
{
  case "yes":
  case "Yes":
  case "YES":
    Message.Text = "Details will be sent.";
    break;
}

My Microsoft C# step by step book (pg 75) says that Fall-Through syntax is 
not allowed with C#.

What is correct?

- Frode
Message #2 by "Paul Birch" <paulbirch@b...> on Sun, 13 Oct 2002 17:20:11 +0100
Wrox is correct in this context.  You cant have fall though in a situation
like this though:
	{
		case <ValueN>:
			doSomething();
		case <valueO>:
			doSomethingElse();
			break;
	}

The case for valueN needs a break or the compiler will complain.

Paul.



-----Original Message-----
From: Frode [mailto:fstroemm@o...]
Sent: 13 October 2002 16:39
To: aspx_beginners
Subject: [aspx_beginners] Switch statement rules


Beginning asp.net 1.0 with C#  explains this on page 228:

switch (Confirmation
{
  case "yes":
  case "Yes":
  case "YES":
    Message.Text = "Details will be sent.";
    break;
}

My Microsoft C# step by step book (pg 75) says that Fall-Through syntax is
not allowed with C#.

What is correct?

- Frode
---
Beginning ASP.NET Databases using VB.NET
http://www.wrox.com/ACON11.asp?ISBN=1861006195

Beginning ASP.NET Databases using C#
http://www.wrox.com/ACON11.asp?ISBN=1861007418

These books look at how we can create data-centric ASP.NET
applications. Requiring some basic knowledge of ASP.NET,
Access and SQL the authors guide you through the process
of connecting and consuming information in a variety of
ways. They are packed full of excellent illustrative code
examples, demonstrating important fundamental principles.


  Return to Index