How to get actual type of an derived class from its parent interface
Posted
by Tarik
on Stack Overflow
See other posts from Stack Overflow
or by Tarik
Published on 2010-03-26T01:46:20Z
Indexed on
2010/03/26
1:53 UTC
Read the original article
Hit count: 604
Hello people,
Lets say we have a code portion like this :
IProduct product = ProductCreator.CreateProduct(); //Factory Method we have here
SellThisProduct(product);
//...
private void SellThisProduct(IProduct product)
{
//..do something here
}
//...
internal class Soda : IProduct
{}
internal class Book : IProduct
{}
How can I infer which product is actually passed into SellThisProduct() method in the method?
I think if I say GetType() or something it will probably return the IProduct type.
Thanks...
© Stack Overflow or respective owner