|
Ah ha! You're reading the "simplified" pages and I'm not surprised that you found ambiguity. Personally I tend to go to the authoritative source, the C# Language Reference. Here you see that
a switch statement consists of "switch" followed by an expression in parentheses followed by a switch block
a switch block consists of 0 or more switch sections, the whole wrapped in braces
a switch section consists of one or more switch labels followed by a list of statements
a switch label is either "case" followed by a constant expression followed by colon, or "default" followed by colon.
It is the statement list that cannot "fall through." (In fact, it's stated as "the end point of a statement list cannot be reachable," by which it means that you cannot get to the point just after the last statement in the statement list. In other words, the last statement in the list must be a "jump" type statement: break, goto, throw, etc.)
Hence, <phew>, you can have code that lokos like this:
switch (foo) {
case 1:
case 2:
DoSomething();
break;
...
}
As to the error message, I agree that it could be a little misleading, although it does correctly talk about the last switch label in the (possible) list of labels.
Cheers, Julian
Program Manager, C#
This posting is provided "AS IS" with no warranties, and confers no rights.
|
|
|
|
|
And the light comes on!
It does makes sense now (and also renders my original post completely moot).
Thanks for clearing up the ambiguity for me Julian!
don
To summarize
legal:
switch case( foo )
{
case 0:
case 1:
DoIt();
break;
} not-legal:
switch ( foo )
{
case 0:
DoOneThing();
case 1:
DoAnotherThing();
break;
} also not legal:
switch ( foo )
{
case 0:
DoOneThing();
break;
default:
DoAnotherThing();
}
|
|
|
|
|
I found that GDI+ has some features for smoothing (SmoothingMode,TextRenderingHint...). MSVisio2002 also uses GDI+ (I suppose). But graphics in Visio and my GDI+ application looks different. It seems that Visio uses another smoothing mode, do you know which ?
|
|
|
|
|
MS used to have a thing called "Browser Helper Object", supporting IE4 (maybe 5). Is there a newer parllel to this? To be specific, I would like to gather statistics on my browser, such as download time of each object in a web page. Are there events raised by IE handling such questions?
at first stage, I don't mind activating the browser programmtically (I gather that the strongest feature of the Browser Helper was that it attached itself to any instance of the browser )
YD
|
|
|
|
|
Hi All,
Recently I loaded a C# project am writing using VS.Net 2002 all of a sudden the development enviroment closes my project by it self. It repeated several time any time I load the project and start coding.
I've even reinstalled VS.Net 2002 in an XP OS, tried to open the same project from another PC (Win2k Pro) having VS.Net 2002 . Visual studio.Net 2002
still close itself after allowing me to work for a while.
I am waiting for your sugestions or advice on what to do. I don't know wheather it is a bug with Visual Studio 2002.
Thanks
(I've posted the same question on Visaul studion IDE board)
|
|
|
|
|
Mmm...
Some tips, XP, XP Service Packs. something wrong with your version...
|
|
|
|
|
I've being using the Vs.net 2002 for about 8 months now. Apart from that, I've tried it in two different OS (XP and WIN2K Pro service 3). For now am even afriad opening it in any other machine running visual studio. I have scanned for virus. The file is not infested with virus. Or does there exist different version of VS.Net 2002?
|
|
|
|
|
Hi, i'd like to learn C#, any book titles suggestion!?
nevhile.net
|
|
|
|
|
Hi there,
I am learning too.
Programming C# 3rd Edition by O'REILLY is pretty good.
|
|
|
|
|
|
Wrox: Professional C# 2nd Edition is fantastic!
Mads
|
|
|
|
|
WebClient objClient= new WebClient();
objClient.DownloadFile("ftp://..../XXXX.txt","c:\\XXXX.txt");
|
|
|
|
|
hi guyz!
actually i have a datset in which i want to filter it according to some condition n then display the required value in the combobox , hope u could help me out , i will be looking forward to ur help thx buddies
Work Hard and Test your Luck
|
|
|
|
|
Use dataset.tables[index].Select to filter the dataset.
I think you should be able to databind the combobox to the dataset using one of it's properties in e.g. designview.
Mads
|
|
|
|
|
Hi everyone
How do get the listview control to force a multiple line display when the
column width is too small?
Anyone written an overide implementation on this? Some sample source will
be most helpful
Many thanks
bchong
|
|
|
|
|
Hi. I want to create a simple notepad.
I used a multiline textbox. I wanted to create a shortcut
for selecting all text in the textbox like pressing ctrl-A would
select all text. Anybody knows how to do this?
Please help me.
"To teach is to learn twice"
|
|
|
|
|
textBox.SelectionStart = 0;
textBox.SelectionLength = textBox.TextLength;
And who modded the parent posting up to 5???
--
-Blake (com/bcdev/blake)
|
|
|
|
|
You can also use textBox.SelectAll().
|
|
|
|
|
I'm new to the C# language, and my Java experience is foiling me here.
My application doesn't really have one main form--it has two (or at least I feel they should be peers). Exactly one of these two windows is visible at any one time, but I'd like the one that IS visible to operate as if it's the main form, in that clicking on the close box of the Form subclass will kill the application. By default, the Form passed to Application.Run(), if closed, kills the entire application. Is there any way to change the main form so that the entire application DOESN'T die just because I call Close() against it. My intent is to create a second (completely different) form, call Show() against it, and then Close() the original one. I could just set it to be invisible, but I'd rather dispose of it entirely and not have to maintain a reference to the Form just so I can call Close() against it when time comes to really kill the application.
Any advice?
|
|
|
|
|
Replace:
Application.Run(myForm);
with:
myForm.Show();
Application.Run();
Alternatively, derive from ApplicationContext and pass one of those into Application.Run(), that's what ApplicationContext's are for.
And don't worry, we won't hold the whole Java thing against you.
--
-Blake (com/bcdev/blake)
|
|
|
|
|
Hi there Blake,
i am pretty new to GUI programming and just picked up C#.
is it possible in anyway that you can point my to an example or tutorial with regards to this?
a little more explaination or examples will be Very much appreciated =)
thanks
|
|
|
|
|
With regards to what exactly?
--
-Blake (com/bcdev/blake)
|
|
|
|
|
opps..
i don't really know the term used but.
for example, i have a form that has a couple of controls then when the users click say "Search DataBase", another form will show the status and then finally transit to a Datagrid that shows the database information.
Must i create 3 seperate forms for them and if yes, how do i transit from form to form?
thanks
|
|
|
|
|
Ah... this is quite a different sort of question than what the original poster asked about.
There's no hard and fast answer, it comes down to style more than anything. That said, I would not use multiple forms for the sort of thing you are describing. Consider instead one form, with actions (like Search Database) chosen from a menu, toolbar or task pane; the status as the search is performed displayed across the status bar and the result grid in the client area all along. All one form, no switching.
--
-Blake (com/bcdev/blake)
|
|
|
|
|
I have a question about enumeration types. I'd like to know if there is a way to iterate through all the literal values? I know if you have:
<br />
enum enumtype {field1, field2, field3};<br />
You can get the symbolic names from the enum using:
<br />
enumtype.field1.ToString();<br />
And I'd like to be able to go through all the posible symbolic names in my enum and add them to a combobox without having to know what all the symbolic names might be right now (because it'll probably change and I'm too lazy to have to change it multiple times!). But enum's don't seem to support and kind of a count property or have anyway of getting the symbolic name when all you know is the underlying int value.
Does anybody know if such a thing is possible with an enum, or should I probably define an array of structs or something similar?
Cheers
|
|
|
|