Julian Gonzalez

Generation

generate functionThu, 30 Mar 2023

create interface with method that return generic object

public interface IHelloWorld { T SayHello<T>(); } public class HelloWorld : IHelloWorld { public T SayHello<T>() { if (typeof(T) == typeof(string)) return (T)(object)"Hello, World!"; else return default(T); } }

Questions about programming?Chat with your personal AI assistant