The reason you can't do it has been explained perfectly by Jeff Louie.
What is the value of polymorphism here ? The main idea behind
Polymorphism being the opposite of what you're doing : being able to
consider various objects as being of the same type (while they are not, but
simply have common attributes and behaviors to allow catching their
similarities) ... here you are trying to deal with dissimilarities through
the common interface ...
If you really having some compelling reasons (I wonder what that could
be) that doesn't show here, you can cast to the specific type before
assigning to the properties :
((LinearGradientBrush)FillBrush).InterpolationColo rs = ...
A more normal and meaning use of polymorhism would look more like :
SolidBrush solidBrush1 = new SolidBrush(...
//assign whatever you need
DoSomething(sildBrush1);
LinearGradientBrush linGradBrush = new LinearGradientBrush(...
//addign InterpolationColors and whatever else you need
DoSomething(linGradBrush);
....
void DoSomething(Brush fillBrush)
{
// code that can apply to any Brush ...
}
"John Baro" <jo***@NOSPAMmesware.com.au> wrote in message
news:l_******************@news-server.bigpond.net.au...
I have declared a brush i.e.
Brush FillBrush;
later
FillBrush = new SolidBrush(....
everything is set in the constructor and then I use the brush to paint.
later
FillBrush = new LinearGradientBrush(...
FillBrush.InterpolationColors = ....
this does not work. It says that InterpolationColours is not defined
etc... Intellisense only shows up the methods, none of the properties, and only
the methods derived from brush.
I thought this should work?
TIA
JB