V
vidalsasoon
//I have a class that has 2 "Render()" implementations.
//I declare them like this:
public class ComplexShape : IEffect, INoEffect{
IEffect.Render(){
...
}
INoEffect.Render(){
...
}
}
//I also have a second class that implements a single render method
public class SimpleShape : INoEffect{
INoEffect.Render(){
...
}
}
//Now my question is:
//I want to use the objects like this:
ISOMEINTERFACE shape; // <-- CONFUSION HERE. I DON'T KNOW WHAT TO
DECLARE.
if(...){
shape = (IEffect)new ComplexShape(...);
}else{
shape = (INoEffect)new SimpleShape(...);
}
shape.Render();
// How could I declare this shape object so I can use it as either
IEffect or // INoEffect
// still getting used to interfaces.
V.
//I declare them like this:
public class ComplexShape : IEffect, INoEffect{
IEffect.Render(){
...
}
INoEffect.Render(){
...
}
}
//I also have a second class that implements a single render method
public class SimpleShape : INoEffect{
INoEffect.Render(){
...
}
}
//Now my question is:
//I want to use the objects like this:
ISOMEINTERFACE shape; // <-- CONFUSION HERE. I DON'T KNOW WHAT TO
DECLARE.
if(...){
shape = (IEffect)new ComplexShape(...);
}else{
shape = (INoEffect)new SimpleShape(...);
}
shape.Render();
// How could I declare this shape object so I can use it as either
IEffect or // INoEffect
// still getting used to interfaces.
V.