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>();

Want to kickstart your project?Use the new AI Studio to create your code