I met some interesting covariance problem in my c# code.
I have a generic Matrix class, and it\'s been instantiated for example Matrix
You have said that you want to be able to insert data into the collection based on the covariantly exposed type. This is simply not possible. For a type to be covariant it needs to not expose any means of inserting data. The type would need to be contravariant to support that, but if the type is contravariant then it cannot expose the information in a covariant manor.
In short, this is impossible, and not just impossible because of what C# as a language has implemented, but impossible on a conceptual level. It's not possible to implement a statically typed solution to this problem in any conceivable language.