Is it possible to refactor this C# if(..) statement?

Posted by Pure.Krome on Stack Overflow See other posts from Stack Overflow or by Pure.Krome
Published on 2010-04-03T11:24:58Z Indexed on 2010/04/03 11:33 UTC
Read the original article Hit count: 202

Filed under:
|
|
|

Hi folks,

simple question :-

i have the following simple if (..) statements :-

if (foo == Animal.Cat || foo == Animal.Dog)
{ .. }

if (baa == 1|| baa == 69)
{ .. }

is it possible to refactor these into something like ...

DISCLAIMER: I know this doesn't compile .. but this is sorta what i'm trying to get...

if (foo == (Animal.Cat || Animal.Dog))
{ .. }

if (baa == (1 || 69))
{ .. }

Cheers :)

EDIT

I wonder if a lambda expression extension could do this? :P

© Stack Overflow or respective owner

Related posts about .NET

Related posts about .net-4.0