Chris Straw
SHARE:

How to instantiate a passed generic type inside a method in C#

public C ExampleMethodName() where C : new()
{
	C returnObject = new C();
	//Other functionality
	return returnObject;
}

To call the method:

var variableName = ExampleMethodName<classGoesHere>();