create new object from generic c#
return (T)Activator.CreateInstance(typeof(T), new object[] { param });
create new object from generic c#
return (T)Activator.CreateInstance(typeof(T), new object[] { param });
c# generic class
public class Car<TManufacturer, TModel,TYear>
{
public TManufacturer manufacturer;
public TModel model;
public TYear year;
public Car(TManufacturer manufacturer, TModel model, TYear year)
{
this.manufacturer = manufacturer;
this.model = model;
this.year = year;
}
}
// after we initialize it with
public Car<string, string, int> car = new Car<string, string, int>();
//by iq18but18cm
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us