Currently doing an assignment where I have to create a custom user control implemented in C#. I mainly have a java background so I don't know if what I am trying to do is possible in C# - if it isn't, could someone please provide me a link or alternative way I can accomplish the same thing in C#.
public abstract class Graph<T,U>
where T : Configuration.GraphConfiguration
where U : Representatives.GraphRepresentative
{
public abstract void Draw(Graphics g);
}
public class LineGraph: Graph<LineGraphConfiguration,LineGraphRepresentative>{
public void draw(Graphics g){
}
}
//"Graph" is not valid since the type params <T,U> are not specified..
//However, I cannot supply them since I don't know until runtime what
//they are. In java just "Graph" or Graph<?,?> would be valid and I need
//something similar.
public class MyCustomControl: UserControl{
Graph currentGraph;
override OnPaint(PaintEventArgs e){
currentGraph.Draw(e.Graphics);
}
}
So basically I need a type or some kind of way of holding both a LineGraph and any other type of Graph - for example later a BarGraph - even if the type params are not the same.