Pretty basic question in C#,
class Data<T>
{
T obj;
public Data()
{
// Allocate to obj from T here
// Some Activator.CreateInstance() method ?
obj = ???
}
}
How do i do this?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
If you want to create your own instance of T, then you need define a constraint
new()If you want to pass in the obj then you need to allow it in the constructor