Re: Knowing an object implements an Interface
- From: Tom Spink <tspink@xxxxxxxxx>
- Date: Fri, 30 Jun 2006 04:38:11 +0100
Ron M. Newman wrote:
Hi,
Is there a quick way to know if a given object implements IComparable?
(without casting or anything like that). Something that uses reflection?
Thanks
-Ron
Hi Ron,
You can use the 'is' operator to test whether or not the given object will
cast to the given type:
if ( obj is IComparable ) { ... }
'obj is IComparable' will evaluate to true if obj can be cast to an
IComparable, i.e. if it implements the IComparable interface.
--
Hope this helps,
Tom Spink
.
- References:
- Knowing an object implements an Interface
- From: Ron M. Newman
- Knowing an object implements an Interface
- Prev by Date: Re: Paging DataGrid
- Next by Date: Re: Unicode and utf 8 /utf 16
- Previous by thread: Re: Knowing an object implements an Interface
- Next by thread: Re: Knowing an object implements an Interface
- Index(es):
Relevant Pages
|