You can use the generic delegate Func<T, TResult> . (See MSDN )
Func<MyType, ReturnType> func = (db) => { return new MyType(); }
There are also useful generic delegates that take into account the return value:
Converter<TInput, TOutput> ( MSDN )Predicate<TInput> - always return bool ( MSDN )
Method:
public MyType SimpleUsing.DoUsing<MyType>(Func<TInput, MyType> myTypeFactory)
General delegate:
Func<InputArgumentType, MyType> createInstance = db => return new MyType();
Performance:
MyType myTypeInstance = SimpleUsing.DoUsing( createInstance(new InputArgumentType()));
OR explicitly:
MyType myTypeInstance = SimpleUsing.DoUsing(db => return new MyType());
sll Nov 11 2018-11-11T00: 00-11
source share