473,473 Members | 1,523 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Check syntax

Whats wrong with this code?

public void CleanData(DataSet DS)

{

switch (DS.Tables[0].TableName.ToString())

{

case "scs_ds_vehicle_inventory" :
case "scs_ds_sold_customer" :

case "scs_ds_employee" :

case "scs_ds_fi_deals" :

case "scs_ds_ro_customer" :

case "scs_ds_ro_history" :

DS.Tables["scs_ds_ro_history"].Columns.Remove("m20");

case "scs_ds_ro_vehicle_history" :

DS.Tables["scs_ds_ro_vehicle_history"].Columns.Remove("m20");

}

}
Nov 15 '05 #1
6 1487
Ruslan Shlain <rs*****@hotmail.com> wrote:
Whats wrong with this code?


You're missing break statements. You aren't allowed to fall through
(except through empty cases statements) in C#.

<snip>

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Nov 15 '05 #2
you need to have a case default
"Ruslan Shlain" <rs*****@hotmail.com> wrote in message
news:eS*************@TK2MSFTNGP12.phx.gbl...
Whats wrong with this code?

public void CleanData(DataSet DS)

{

switch (DS.Tables[0].TableName.ToString())

{

case "scs_ds_vehicle_inventory" :
case "scs_ds_sold_customer" :

case "scs_ds_employee" :

case "scs_ds_fi_deals" :

case "scs_ds_ro_customer" :

case "scs_ds_ro_history" :

DS.Tables["scs_ds_ro_history"].Columns.Remove("m20");

case "scs_ds_ro_vehicle_history" :

DS.Tables["scs_ds_ro_vehicle_history"].Columns.Remove("m20");

}

}

Nov 15 '05 #3
Marco Martin <ma**********@sympatico.ca.antispam> wrote:
you need to have a case default


No you don't. For instance:

using System;

class Test
{

static void Main()
{
int i=3;

switch (i)
{
case 0:
Console.WriteLine ("i was 0");
break;
}
}
}

compiles fine.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Nov 15 '05 #4
Which kind of makes break statements redundant (I mean, if you cannot fall
through, what is the purpose of the break?)...

Alek

"Jon Skeet [C# MVP]" <sk***@pobox.com> wrote in message
news:MP************************@msnews.microsoft.c om...
Ruslan Shlain <rs*****@hotmail.com> wrote:
Whats wrong with this code?


You're missing break statements. You aren't allowed to fall through
(except through empty cases statements) in C#.

<snip>

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too

Nov 15 '05 #5

Have a look at
http://groups.google.co.uk/groups?q=...phx.gbl&rnum=1
(watch for line wrapping) for an explanation

"Alek Davis" <alek_xDOTx_davis_xATx_intel_xDOTx_com> wrote in message
news:uR**************@tk2msftngp13.phx.gbl...
Which kind of makes break statements redundant (I mean, if you cannot fall
through, what is the purpose of the break?)...

Alek

"Jon Skeet [C# MVP]" <sk***@pobox.com> wrote in message
news:MP************************@msnews.microsoft.c om...
Ruslan Shlain <rs*****@hotmail.com> wrote:
Whats wrong with this code?


You're missing break statements. You aren't allowed to fall through
(except through empty cases statements) in C#.

<snip>

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too


Nov 15 '05 #6
Thanks Ed,

I expected the explanation to be the same, but I cannot agree with the
rationale behind it, i.e. making it obvious for C/C++ programmers. Since I
was coming from C/C++ background (7+ years), I assumed that switches in C#
allowed fall-through (since I knew that there were break statements).
Thinking logically, I thought that if you had a break statement, there must
have been an option to fall through. Although, after the first compiler
error, I figured out that my assumption was wrong, so if there are C/C++
programmers who were supposed to benefit from the redundancy, I am not one
of them. In my mind, it is a miss (not the best design decision) and for
every argument for it, I can probably give an argument against. Not a reason
to start religious war, though. There are many issues which are more
serious. ;-)

Alek

"Ed Courtenay" <my***********@edcourtenay.co.uk> wrote in message
news:uE**************@TK2MSFTNGP12.phx.gbl...

Have a look at
http://groups.google.co.uk/groups?q=...phx.gbl&rnum=1 (watch for line wrapping) for an explanation

"Alek Davis" <alek_xDOTx_davis_xATx_intel_xDOTx_com> wrote in message
news:uR**************@tk2msftngp13.phx.gbl...
Which kind of makes break statements redundant (I mean, if you cannot fall through, what is the purpose of the break?)...

Alek

"Jon Skeet [C# MVP]" <sk***@pobox.com> wrote in message
news:MP************************@msnews.microsoft.c om...
Ruslan Shlain <rs*****@hotmail.com> wrote:
> Whats wrong with this code?

You're missing break statements. You aren't allowed to fall through
(except through empty cases statements) in C#.

<snip>

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too



Nov 15 '05 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: leegold2 | last post by:
Newbie question: In Perl I could do #perl -c myscript.pl and with that "-c" it won't run, but will just "compile" it, so I get all my syntax errors. Is there a similar thing in PHP? A way...
20
by: | last post by:
If I need to check if a certain value does exist in a field, and return either "yes" or "not" which query would be the most effestive?
2
by: Jonathan | last post by:
I am looking for a simple way to check if a database table exists. I keep getting advice to use "Try.. Catch" and other error handling methods, but I obviously don't want to have to display an...
1
by: Dharmesh Gandhi | last post by:
DB-Library Error 10007: General SQL Server error: Check messages from the SQL Server. CREATE PROCEDURE . ( @srvr varchar(50),
8
by: BobTheDatabaseBoy | last post by:
the following syntax is accepted: alter table DB2ADMIN.APPTS add constraint appts_status check (lob_appt_status in ( case when state_code = 'VA' then 'P' -- , 'I' else 'X'
15
by: Rey | last post by:
Howdy all. Appreciate your help with several problems I'm having: I'm trying to determine if the Visit subform (subformVisits) has a new record or been changed, i.e. dirty. The form that...
18
by: Joel Hedlund | last post by:
Hi! The question of type checking/enforcing has bothered me for a while, and since this newsgroup has a wealth of competence subscribed to it, I figured this would be a great way of learning...
1
by: gajewski.konrad | last post by:
Hi All. I'm newbee. I try to check syntax any XML file. I don't have any dtd or shema file to this xml. Is this possible that I check syntax in any xml file in python. Regards, Dreamen
5
by: lokeshrajoria | last post by:
hello everyone, i am new in this community. i have some problem in checking and validation of data acording to syntax. which i have given below.. my problem is i want to check...
4
by: FM | last post by:
Hi there: My question is about checking my sql-syntax against DB2UDB V9 throug JDBC 2.0 Is there a way to check my syntax,for example "select * from T1"? Thank you for your help. Regards,
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.