Can anyone tell me if there is a way with generics to limit a generic type argument T
to only:
Int16
Int32
I would use a generic one which you could handle externaly...
///
/// Generic object copy of the same type
///
/// The type of object to copy
/// The source object to copy
public T CopyObject(T ObjectSource)
{
T NewObject = System.Activator.CreateInstance();
foreach (PropertyInfo p in ObjectSource.GetType().GetProperties())
NewObject.GetType().GetProperty(p.Name).SetValue(NewObject, p.GetValue(ObjectSource, null), null);
return NewObject;
}