C# Calling Methods in Generic Classes
Posted
by aip.cd.aish
on Stack Overflow
See other posts from Stack Overflow
or by aip.cd.aish
Published on 2010-03-14T20:14:41Z
Indexed on
2010/03/14
20:25 UTC
Read the original article
Hit count: 282
I am extending the ImageBox control from EmguCV. The control's Image
property can be set to anything implementing the IImage
interface.
All of the following implement this interface:
Image<Bgr, Byte>
Image<Ycc, Byte>
Image<Hsv, Byte>
Now I want to call the Draw
method on the object of the above type (what ever it may be).
The problem is when I access the Image property, the return type is IImage
. IImage does not implement the Draw
method, but all of the above do.
I believe I can cast the object of type IImage
to one of the above (the right one) and I can access the Draw
method. But how do I know what the right one is? If you have a better way of doing this, please suggest that as well.
© Stack Overflow or respective owner