c# - Difference between Covariance & Contra-variance -
I am having trouble understanding the difference between empathy and immorality.
The question is, "What is the difference between sympathy and corruption?"
Sovereignty and depravity are the properties of a mapping function that connects one member of a set with another. More specifically, a mapping can be a cult or anti in relation to relationship on that set.
Consider the following two subsets of the set of all C # types. First:
{animal, tiger, fruit, banana}. And secondly, this is clearly related to the set:
{IEnumerable & lt; Animals>, IEnumerable & lt; Tiger & gt;, IEnumerable & lt; Feet & gt ;, IEnumerable & lt; Banana & gt; } There is an mapping operation from the first set to the second set. For each T in the first set, in the second set related type IEnumerable & lt; T & gt; . Or, in a nutshell, mapping T → IE & lt; T & gt; . Note that this is a "thin arrow".
So far with me?
Now we consider an relationship . In the first set, there is an assignment consistency relationship between pairs. A value of type tiger can be assigned to a variable of , so these types are called "assignment compatible". Let us type "a value of type X can be specified as a lower type in y " "
So in our first subset, here are all assignment compatibility relationships:
Tiger ⇒ Tiger Tiger ⇒ Animal Animal ⇒ Animal Creation ⇒ Banana made ⇒ fruit fruits ⇒ fruit In C # 4, supporting the co-sensitive sensitivity of some interfaces, the type of pair in the second set The Quick Assignment Compatibility Relationship is:
IE> Tiger> ⇒ IE IE & LT; Tiger & gt; ⇒ IE & lt; Animals & gt; IE & LT; Animals> ⇒ IE & lt; Animals & gt; IE & LT; Banana> ⇒ IE & lt; Banana & gt; IE & LT; Banana & gt; ⇒ IE & lt; Fruits & gt; ; IE & LT; Fruits & gt; ⇒ IE & lt; fruit & gt; Note that mapping T → IE >> Assignment preserves the existence and direction of compatibility That is, if X ⇒ Y , then it is also true that IE
If we have two things on both sides of the fat arrow, then we can turn both sides towards the right hand of a thin arrow.
Mapping This property is called "sympathetic mapping" in relation to a particular relationship. It should be understood: where the sequence of tigers can be used, where the sequence of animals is but the opposite is not true. A sequence of animals can not be needed where a series of tigers are required.
This community is now considering this subset of all types of sets:
{ICemperable & lt; Tiger & gt;, ICemperable & lt; Animals>, IComperbol & lt; Fert>, IComperbal & lt; Banana & gt; } We now have the third set T → IC & lt; T & gt; There is a mapping on .
In C # 4:
IC < Tiger & gt; ⇒ IC & lt; Tiger & gt; IC & LT; Animals & gt; ⇒ IC & lt; Tiger & gt; Backwards! IC & LT; Animals & gt; ⇒ IC & lt; Animals & gt; IC & LT; Banana & gt; ⇒ IC & lt; Banana & gt; IC & LT; Fruit & gt; ⇒ IC & lt; Banana & gt; Backwards! IC & LT; Fruit & gt; ⇒ IC & lt; Fruit & gt; That is, the mapping T → IC & lt; T & gt; has preserved existence but direction of compatibility assignment is the same, if x ⇒ y , then ic < X & gt; A mapping that holds , but goes back is a relation called contravariant mapping.
Therefore there is a difference between sovereignty and corruption in C # 4. > Maintenance direction of assignment In contrast, behind
Comments
Post a Comment