Ive a class that implement the IMarcas interface:
public class BaseQuestao : IMarcas
{
public string TxtMarca
{
get;
set;
}
}
Where TxtMarca property is an assignture from that interface.
Problem is that when i try to execute follow code is says that BasesQuestao is NOT IMarcas:
BaseQuestao bs = new BaseQuestao();
IMarcas brand = bs as IMarcas;
if (brand != null)
{
bs.TxtMarca = "voila";
}
Any ideias?
As others have said, you’re using the wrong variable (
bsinstead ofbrand) – but it would have worked either way.Here’s an example with the code corrected:
and even with the original code:
… it’s still fine.