I Create Generic class like this:
public class Sample<T> where T : class
{
public DoSomething();
}
then I create new class :
public class Sample2
{
Sample<Sample2> obj=new Sample<Sample2>();
}
why can't i use the below code to create an instance of Sample
class in Sample2
class?
Sample<typeof<this>> obj=new Sample<typeof<this>>();
答案很简单泛型需要Compile time
但是你在Compile time
显然不知道你正在做什么
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.