covariance
Covariance and contravariance for wildcarded types
Can you please explain why it is possible to do: import java.util.ArrayList; import java.util.List; public class Covariance {[详细]
2023-03-08 07:11 分类:问答Inheritance & Lists
Class B extends class A. I have a list of B (List<B> list1), but for some operations I need only class A fields, but List<A> list2 = list1 doesn\'t work. H开发者_如何学Cow can this problem[详细]
2023-03-07 08:18 分类:问答Why doesn't this generic extension method compile?
The code is a little weird, so bear with me (keep in mind this scenario did come up in production code).[详细]
2023-03-06 08:37 分类:问答Question about generics in C# comparing to Java
In Java I can specify generic with wildcard \"?\". It is possible to create a map like this one: Map<String, ?>.[详细]
2023-03-05 16:29 分类:问答Invalid Types in VB.NET
I have a function which returns a list of products and a page which displays then, but when I try to load the list on the page, I get a cryptic error:[详细]
2023-03-04 13:45 分类:问答Type extraction in Scala
I am pretty new to Scala and advanced programming languages. I try to solve the following problem. I have got:[详细]
2023-03-03 19:55 分类:问答Why can't I cast from a List<MyClass> to List<object>?
I have a List of objects, which are of my type QuoteHeader and I want to pass this list as a list of objects to a method which is able to accept a List<object>.[详细]
2023-03-02 22:39 分类:问答c++: exact type of contained objects without casts
I got the classic Shape hierarchy example... struct Shape { // abstract type Shape (int x, int y); int x;[详细]
2023-03-02 20:01 分类:问答Referencing a derived type inside itself
I have something link this: public abstract class Wrapper<T, TWrapped>: where TWrapped : Wrapper<T, TWrapped>[详细]
2023-03-02 13:05 分类:问答Covariance and IList
I would like a Covariant collection whose items can be retrieved by index.IEnumerable is the only .net collection that I\'m aware of that is Covariant, but it does not have this index support.[详细]
2023-03-02 03:09 分类:问答