Please first read below ----
Its correct that I'm debugging and using VS.NET 2002
with .net ver 1.0 - If I run a release version in 2002 or
run it under VS.NET 2003 with .net ver 1.1 there is no
problem.
Is it VS.NET or the version of .Net that is the problem.
Are there any service packs to solve the problem for
VS.NET 2002.?
best regards?
-----
Within the following construction
switch (expression)
{
int i;
i = GetArgs() //return 2
case constant-expression:
if ( 2 == i )
{
//statement 1
}
else
{
//statement 2
}
break;
case constant-expression:
....
break;
}
(the switch block is nested within a try using catch
block)
I get execution of both statements!!!!. I thought I was
an experienced c++ programmer (10y+) migrating to C# but
I can't see what I'm doing wrong. If I take the code
snippet and puts it over in another project it works
fine, hence the syntax is ok. If I instead of ( 2 == i )
writes ( true ) it also works fine.
Please advise
best regards Jesper
..
Jesper Denmark wrote:
I get execution of both statements!!!!. I thought I was
an experienced c++ programmer (10y+) migrating to C#
That explains the somewhat hard to read
if (2==i)
syntax rather than the more natural (and just as safe in
C#)
if (i==2)
syntax...
but I can't see what I'm doing wrong. If I take the code
snippet and puts it over in another project it works
fine, hence the syntax is ok. If I instead of ( 2 == i )
writes ( true ) it also works fine.
My guess is that you're using VS.NET 2002 and running in
the debugger -
there are known bugs which show this kind of behaviour.
Try running it
not in the debugger and all should be well.
--
Jon Skeet -
http://www.pobox.com/~skeet/
If replying to the group, please do not mail me too
..