samedi 21 mars 2015

Reflection method to Draw shape in C# winform

I have a blank method



void DrawShape(Graphics g, int x, int y){

}


I want to pass the "method body" as a string on runtime, to draw a shape by my code, ex:



y =0;
while(x<100){
x++;
g.drawRectangle(rec1, x,y);
}


and the method will execute like:



void DrawShape(Graphics g, int x, int y){
y =0;
while(x<100){
x++;
g.drawRectangle(rec1, x,y);
}
}


It's will be wonderful, but I don't know how to do that. Any help appreciated






Aucun commentaire:

Enregistrer un commentaire