In -depth understanding of the coordination and inversion in C#
The concepts of coordination and inverting are often confusing. This article will explore the essence of collaborative and inverse, and clarify its usage through specific examples.
What is a coordinated change?
Coordination is a characteristic of the refreshment function to maintain the direction of assignment compatibility. Suppose we have a mapping from collection A to collection B, which is recorded as A → B. If A and B are correlated through the relationship R, where the AR B, when ARB contains f (a) RF (b), the mapping is a coordinated change. For example, the mapping T → Ienumeability
converts the type T to its corresponding IenumeRable collection type. In C#, this mapping is coordinated, because the object of the type T can be assigned to the object of the type Ienumerable, so you can use IenuMerable
where you need Ienumeration & LT; derived type & gt; & lt;/derived type & gt;
(where C indicates a comparison or standard type) maintains the relationship R, but reverse its direction. In other words, if AR B, C ⇐ C
.
The coordinated and inverter in the c#
The above is the detailed content of Covariance vs. Contravariance: What's the Difference and How Are They Used in C#?. For more information, please follow other related articles on the PHP Chinese website!