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

Home Posts Topics Members FAQ

Conditional Assignment

Hi All,

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?

Thanks!

-Emily

Jan 17 '07 #1
1 1325
Fir5tSight <fi********@yahoo.comwrote:
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 - <sk***@pobox.com>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too
Jan 17 '07 #2

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

Similar topics

26
by: Ney André de Mello Zunino | last post by:
Hello. I have noticed, in a lot of C and C++ code, that many programmers seem to prefer putting the test values first in conditional expressions. I.e., they would rather write this: if (-1 ==...
92
by: Raghavendra R A V, CSS India | last post by:
hie.. Do any one knows how to write a C program without using the conditional statements if, for, while, do, switch, goto and even condotional statements ? It would be a great help for me if...
4
by: mux | last post by:
Hi I found out that the following piece of code throws an error. 1 #include "stdio.h" 2 3 int main() 4 { 5 int a,b; 6 a= 10;
2
by: Rob Williams | last post by:
The following code will not compile... public bool active = false; public void Activate(){} public void Deactivate(){} public void object_Activate(object sender, EventArgs e){ (active)?...
5
by: xamdam | last post by:
I am not sure if this came up before, but I would love to have an 'assignment-in-conditional' form in python, e.g pat = re.compile('something') if m = pat.match(s): m.group(1) Of course...
5
by: paulo | last post by:
Can anyone please tell me how the C language interprets the following code: #include <stdio.h> int main(void) { int a = 1; int b = 10; int x = 3;
4
by: Colin J. Williams | last post by:
It would be helpful if the rules of the game were spelled out more clearly. The conditional expression is defined as X if C else Y. We don't know the precedence of the "if" operator. From the...
43
by: dev_cool | last post by:
Hello friends, I'm a beginner in C programming. One of my friends asked me to write a program in C.The purpose of the program is print 1 to n without any conditional statement, loop or jump. ...
2
by: Paul | last post by:
Can you help me with this error? string fields = string.Empty; .... fields.Length 0 ? fields += ", Name" : fields += "Name"; Error: Only assignment, call, increment, decrement, and new...
4
by: Zack | last post by:
Hi, Let's say you have this function named validate. validate looks like this: function validate() { return ($F("Email") != '' ? ($("Name").value = $F("Email")) : false); }
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...
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: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.