|
-
Dec 9th, 2004, 03:19 AM
#1
Thread Starter
Fanatic Member
()?: Question
Is there something wrong in my code?
Code:
(i%2==0)?li.BackColor=Color.White:li.BackColor=Color.OldLace;
BTW, li is a ListViewItem. Thank you. 
edit: The error is "Only assignment, call, increment, decrement, and new object expressions can be used as a statement"
Last edited by brown monkey; Dec 9th, 2004 at 08:53 PM.
-
Dec 9th, 2004, 08:58 AM
#2
Frenzied Member
Re: ()?: Question
As far as I'm aware, it goes
Code:
(expression)?statement:statement;
I don't think you can actually use expressions in place of the statements. It's just for returning values.
Try
Code:
if ( i%2 == 0 )
{
li.BackColor = Color.White;
}
else
{
li.BackColor = Color.OldLace;
}
I'm pretty sure that will work.
-
Dec 9th, 2004, 09:29 AM
#3
Frenzied Member
Re: ()?: Question
Oh I just thought of something actually;
Code:
li.BackColor = (i%2 == 0)?Color.White:Color.OldLace;
Try that
-
Dec 9th, 2004, 08:17 PM
#4
Thread Starter
Fanatic Member
Re: ()?: Question
 Originally Posted by TomGibbons
Oh I just thought of something actually;
Code:
li.BackColor = (i%2 == 0)?Color.White:Color.OldLace;
Try that 
God. I'm totally lost. Thank you, Tommy.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|