Julian Gonzalez

Generation

generate functionThu, 30 Mar 2023

How to return a generic object in c#

public static class GenericFactory { public static T Get<T>() where T : new() { return new T(); } } // Usage: Person person = GenericFactory.Get<Person>();

Questions about programming?Chat with your personal AI assistant