Reputation: 370
I want to make an animator class in C# that will perform some effects on objects (like sliding them right/left, changing their opacity, etc.) And I wonder if it is possible to call a function with any type of object as a parameter instead of having overloaded functions: one for labels, another for pictureBoxes and another one for panels.
Upvotes: 2
Views: 151
Reputation: 1730
You have two options:
MyFunction<T>()
I'd recommend the first option. Lots more info about it here on stack overflow and also on the MSDN
Upvotes: 0
Reputation: 64943
Your animator method will need to accept Control
instances, where Control
is the base class of any control.
Upvotes: 2
Reputation: 23591
Yes. Use a common base type. In your case this is probably Control
Upvotes: 4