> > if( (myList!=null) && (myList.Count>10) )
> > {
[quoted text clipped - 12 lines]
>
> Jon
I agree with Jon. Unless you have multiple threads modifying myList at
the same time C# will do as you expect, i.e. evaluate only as much of
the expression as necessary. Actually, in a release build the two
pieces of code compile to the exact same IL.
If you do in fact have multiple threads here, both solutions are
equally flawed as checking and accessing myList is not a single
operation in either of the cases. In that case, you need
synchronization.
Brian
Sin Jeong-hun - 27 May 2008 14:38 GMT
> > > if( (myList!=null) && (myList.Count>10) )
> > > {
[quoted text clipped - 24 lines]
>
> Brian
That was weird. I tested it but it caused no exception. Actually, that
was not exactly the same situation which I usually encounter while I'm
programming. I can't recreate the code that caused an exception right
now. When I it comes to me, I will post it again.
I'm sorry for having caused troubles by asking you a wrong question.
Thank you.