本文介绍了引用C#泛型,但不关心类型的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

限时删除!!

你好,

假设您要引用泛型实例,例如BindingList< t>.但不在乎T的类型.

例如,如果您有一个名为SomeClass的类,且该类的构造函数需要BindingList< t>的实例.但不在乎T的类型是什么:

Hi there

Suppose you wanted to reference an instance of a generic such as BindingList<t> but don''t care about the type of T.

For example, if you have a class called SomeClass with a constructor that wants an instance of BindingList<t> but doesn''t care about what T''s type is:

public class SomeClass
{
    public SomeClass(BindingList<t> someList)
    { }
}


有没有一种方法可以使SomeClass不通用:例如SomeClass< t>


is there a way to do this without making SomeClass a generic: e.g SomeClass<t>

推荐答案


public class SomeClass
{
  public SomeClass(IBindingList someList)
  { }
}


这篇关于引用C#泛型,但不关心类型的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

1403页,肝出来的..

09-08 17:59