Re: Conditional Assignment



Fir5tSight <fir5tsight@xxxxxxxxx> wrote:
I have the following code in C#:

lSelectedFilter = 1;
this.tabFilters.SelectedIndex = (lSelectedFilter == 0 ? 0
: lSelectedFilter - 1);

After executing the above statements, this.tabFilters.SelectedIndex is
changed to -1. Why? I expected it to be 0. Anyone can explain it to me?

You should work out whether the problem is with the value you're trying
to assign to SelectedIndex, or the SelectedIndex property itself.

Could you post a short but complete program which demonstrates the
problem?

See http://www.pobox.com/~skeet/csharp/complete.html for details of
what I mean by that.

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