How to get actual type of an derived class from its parent interface
- by Tarik
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...