[Mono-list] Object additional implicit operator.

d3x0r d3ck0r at gmail.com
Thu Aug 14 20:59:09 EDT 2008




Since this is open source, I was going to patch my own copy to add an
extension to 'Object'.

public static implicit operator bool( Object o ) { 
  return (o!=null); 
}

but, the compiler throws an error 'cannot convert to or from a derived
class'

since this is IN Object, how can it be a 'derived' class?

I got really used to testing to objects as...

if( thing )
{
    // okay do something with thing.
}

and 

if ( !thing )
{
   // probably create a thing....
}


-- 
View this message in context: http://www.nabble.com/Object-additional-implicit-operator.-tp18992151p18992151.html
Sent from the Mono - General mailing list archive at Nabble.com.



More information about the Mono-list mailing list