Based on your comments, I imagine you have an object of an unknown type that you want to pass to a generic function that requires the passed-over object to be of the generic type argument, which has to have a parameterless constructor. Hence, for the time being, we can assume that your function Save1<T>(T)
from your question is that function, not written by you, not possible to be changed.
A solution to this would be to make the call by using reflection:
- Find the
MethodInfo
of the method you are trying to call by usingType.GetMethod
. - Construct the
MethodInfo
of the method for your parameterless-constructor-type by specifying type arguments withMakeGenericMethod
. - Invoke the method by calling the
MethodInfo.Invoke
method.