[英]in C# can we do something like this List<? of CustomType>
I have a custom type, which is abstract. 我有一个自定义类型,它是抽象的。 and will have some class to extend the abstract class.
并将有一些类来扩展抽象类。
somewhere i need to deal with a list of object which are the children my custom abstract type. 某处我需要处理一个对象列表,这些对象是我自定义抽象类型的子对象。
i am wonder in C#, can i do somthing like this: 我在C#中很奇怪,我能做这样的事吗:
void Method(List<? is CustomType> objs)
{
}
thx 谢谢
void Method<T>(List<T> objs)
where T : CustomType
{
}
i think what you are looking for is a generic method. 我认为你在寻找的是一种通用的方法。 Those are definitely supported:
这些肯定是支持的:
void Method<T>(List<T> objs) where T: CustomType
{
}
MSDN on generics: http://msdn.microsoft.com/en-us/library/ms379564(v=vs.80).aspx 关于泛型的MSDN: http : //msdn.microsoft.com/en-us/library/ms379564( v = vs.80).aspx
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.