Checking whether a class implements and interface

  • Thread starter Thread starter Krish
  • Start date Start date
K

Krish

I have an object of a class. Now I want to know whether this class
implements a particular interface or now.
How do i do that.

Interface ISomeInterface
{
}

MyClass objCls= new MyClass();

//how do I check from objCLS whether MyClass implements the
ISomeInterface interface or not?

Thanks in advance
Kris
 
Krish

use the is operator:

for example:

if( objCls is ISomeInterface) { ... }

Hope that helps,

Ralph Shillington
Check out Coffee Break Tutorials (http://www.ifoundtime.com/community)
for 3 to 5 minute video demonstrations of common .NET and SQL Server
develpoment questions.
 
Back
Top