JRockFL
asked on
Opposite of "is"
What would be the opposite? (ie (if page not INonSecure page)
if (Page is INonSecurePage)
//do some stuff
if (Page is INonSecurePage)
//do some stuff
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
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
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thank you DarkoLord, that is what I needed.
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