Here to get you started:
public Object Parse(String stringValue, Type typ)
{
Type[] parseParams = new Type[] { typeof(String) };
Object retVal = null;
MethodInfo mi = typ.GetMethod("Parse", parseParams);
if (mi != null)
{
retVal = mi.Invoke(this, new Object[] { stringValue });
}
return retVal;
}
private D GetValue<D>(Textbox tb)
{
D result = default(D);
try
{
result = (D)Parse(tb.Text, typeof(D));
}
catch
{
}
return result;
}
private T DoSum<T>(Textbox[] textboxes)
{
T result = default(T);
foreach(Textbox tb in textboxes)
{
result = Add<T>(result, GetValue<T>(tb));
}
}
private L Add<L>(L result, L addend)
{
L result = default(L);
...
...
...
return result;
}
Cheers!
—MRB