D
Dave H
I have a generic class similar to below that is responsible for returning
classes as Interfaces, where IBook and ICard are known interfaces.
public sealed class StoreManager {
private StoreManager() { }
public IBook GetBook() {
return (IBook) new Book();
}
public ICard GetCard() {
return (ICard) new Card();
}
}
The question I have is do I type cast and return interfaces in the
StoreManager class as above and grab them like this:
IBook _myBook = StoreManager.GetBook();
or
should for example GetBook look like this:
public Book GetBook() {
return new Book();
}
and I grab it like this (doing the type casting now):
IBook _myBook = (IBook)StoreManager.GetBook();
I hope I am making sense.
Best Regards,
Dave
classes as Interfaces, where IBook and ICard are known interfaces.
public sealed class StoreManager {
private StoreManager() { }
public IBook GetBook() {
return (IBook) new Book();
}
public ICard GetCard() {
return (ICard) new Card();
}
}
The question I have is do I type cast and return interfaces in the
StoreManager class as above and grab them like this:
IBook _myBook = StoreManager.GetBook();
or
should for example GetBook look like this:
public Book GetBook() {
return new Book();
}
and I grab it like this (doing the type casting now):
IBook _myBook = (IBook)StoreManager.GetBook();
I hope I am making sense.
Best Regards,
Dave