Automatic code generation based on a class
Posted on 2014-01-22
Before anyone rants about it - yes I am aware of the ambiguous title - i was having a hard time phrasing my question into 1 line.
Say I have a very simple class like so:
public int i;
public string str1;
public double d;
private int pvt_i;
is there a tool or way to automatically generate code based on this class like so:
ANewClass o = new ANewClass(); // user types this
// this bit gets automatically generated
o.i = 0;
o.str1 = "";
o.d = 0;
The reason I would like to know something like this is because we have some classes that literally have hundreds of really simple public members like the example and I would like to generate a assigned default value (non-null) for them. I understand that this could be done within the original class itself, but I would like to control the (default) assignment.