inline - How not to repeat a statement that is repeating in my method in C#? -


i hate repeat line @ below function:

public void print() {    verticalposition += bodyfontheight;    printdata(something);     verticalposition += bodyfontheight;    printdata(something else);     verticalposition += bodyfontheight;    printdata(something else else); } 

i thought write inline function in c/c++ , first attempt func delegate.

but unfortunately func not allow using ref or out parameters.

any ideas should done in case ?

you can put things in collection want

things = {something,something else, else else}; 

and then, loop on

public void print() {    foreach (thing in things){       verticalposition += bodyfontheight;       printdata(thing);    } } 

Comments

Popular posts from this blog

php - Submit Form Data without Reloading page -

linux - Rails running on virtual machine in Windows -

php - $params->set Array between square bracket -