concept different type in category .net

appears as: different type, different types, different types
C# in Depth

This is an excerpt from Manning's book C# in Depth.

You now have properties with private setters (which you use in the constructor), and it doesn’t take a genius to guess that List<Product> is telling the compiler that the list contains products. Attempting to add a different type to the list would result in a compiler error, and you also don’t need to cast the results when you fetch them from the list.

You may already be aware that C# 4 offers generic covariance and contravariance for delegates and interfaces. This is entirely different from the variance we’re looking at here—we’re only dealing with creating new instances of delegates at the moment. The generic variance in C# 4 uses reference conversions, which don’t create new objects—they just view the existing object as a different type.

Listing 7.8. Working with different types of the same type in different assemblies
// Compile with // csc Test.cs /r:FirstAlias=First.dll /r:SecondAlias=Second.dll extern alias FirstAlias;  #1 extern alias SecondAlias; using System; using FD = FirstAlias::Demo;  #2 class Test {    static void Main()    {       Console.WriteLine(typeof(FD.Example));  #3       Console.WriteLine(typeof(SecondAlias::Demo.Example)); #4    } } #1 – 1 Specifies two extern aliases #2 – 2 Refers to extern alias with namespace alias #3 – 3 Uses namespace alias #4 – 4 Uses extern alias directly !@%STYLE%@! {"css":"{\"css\": \"font-weight: bold;\"}","target":"[]"} !@%STYLE%@!