Link to home
Start Free TrialLog in
Avatar of JRockFL
JRockFLFlag for United States of America

asked on

Opposite of "is"

What would be the opposite?  (ie (if page not INonSecure page)

            if (Page is INonSecurePage)
                //do some stuff
Avatar of bramsquad
bramsquad
Flag of United States of America image

Are you talking about VB or C#

depending on if something returns a boolean value or if its comparing values you would do this

// compare values (Page does not equal INonSecurePage)

if ( Page != INonSecurePage)
{ //do stuff }

// boolean

if ( !Page )
{  // do stuff }

VB is going to have different syntax, let me know if thats what you want.

Thanks

~b
You can do what you need with a cast.
INonSecure nsPage = Page as INonSecure;
if (nsPage != null) //The cast succeeded
{
   // do stuff
}
else // the cast failed
{
   // do other stuff
}

Using as gives you a cast that will not throw exceptions. Returns null if the cast is invalid.

Jim
BTW - Since this appeared in the C# zone, I assumed C#.
ASKER CERTIFIED SOLUTION
Avatar of DarkoLord
DarkoLord
Flag of Slovenia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of JRockFL

ASKER

Thank you DarkoLord, that is what I needed.