Checking whether a class implements and interface

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
 
R

rshillington

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top