﻿<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/"><channel><title>博客园-装配中的脑袋-最新评论</title><link>http://www.cnblogs.com/Ninputer/CommentsRSS.aspx</link><description>用大脑装配程序，再用程序装配大脑</description><language>zh-cn</language><pubDate>Tue, 03 Jan 2012 07:08:34 GMT</pubDate><lastBuildDate>Tue, 03 Jan 2012 07:08:34 GMT</lastBuildDate><generator>cnblogs</generator><item><title>Re:C++ AMP实战：绘制曼德勃罗特集图像</title><link>http://www.cnblogs.com/Ninputer/archive/2012/01/03/2310945.html#2285558</link><dc:creator>木野狐(Neil Chen)</dc:creator><author>木野狐(Neil Chen)</author><pubDate>Tue, 03 Jan 2012 07:32:34 GMT</pubDate><guid>http://www.cnblogs.com/Ninputer/archive/2012/01/03/2310945.html#2285558</guid><description><![CDATA[脑袋 v5, 前排占座学习~<br><br><div align=right><a style="text-decoration:none;" href="http://www.cnblogs.com/Ninputer/" target="_blank">木野狐(Neil Chen)</a> 2012-01-03 15:32 <a href="http://www.cnblogs.com/Ninputer/archive/2012/01/03/2310945.html#2285558#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>Re:C++ AMP实战：绘制曼德勃罗特集图像</title><link>http://www.cnblogs.com/Ninputer/archive/2012/01/03/2310945.html#2285551</link><dc:creator>一线码农</dc:creator><author>一线码农</author><pubDate>Tue, 03 Jan 2012 07:20:24 GMT</pubDate><guid>http://www.cnblogs.com/Ninputer/archive/2012/01/03/2310945.html#2285551</guid><description><![CDATA[脑袋大神来了，顶一下。<br><br><div align=right><a style="text-decoration:none;" href="http://www.cnblogs.com/Ninputer/" target="_blank">一线码农</a> 2012-01-03 15:20 <a href="http://www.cnblogs.com/Ninputer/archive/2012/01/03/2310945.html#2285551#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>Re:C++ AMP实战：绘制曼德勃罗特集图像</title><link>http://www.cnblogs.com/Ninputer/archive/2012/01/03/2310945.html#2285544</link><dc:creator>陈梓瀚(vczh)</dc:creator><author>陈梓瀚(vczh)</author><pubDate>Tue, 03 Jan 2012 07:12:24 GMT</pubDate><guid>http://www.cnblogs.com/Ninputer/archive/2012/01/03/2310945.html#2285544</guid><description><![CDATA[前排祝贺<br><br><div align=right><a style="text-decoration:none;" href="http://www.cnblogs.com/Ninputer/" target="_blank">陈梓瀚(vczh)</a> 2012-01-03 15:12 <a href="http://www.cnblogs.com/Ninputer/archive/2012/01/03/2310945.html#2285544#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>Re:自己动手开发编译器（十二）生成托管代码</title><link>http://www.cnblogs.com/Ninputer/archive/2011/12/22/2120435.html#2276858</link><dc:creator>Haven</dc:creator><author>Haven</author><pubDate>Thu, 22 Dec 2011 08:03:31 GMT</pubDate><guid>http://www.cnblogs.com/Ninputer/archive/2011/12/22/2120435.html#2276858</guid><description><![CDATA[好文章，感谢楼主分享，受益匪浅！<br><br><div align=right><a style="text-decoration:none;" href="http://www.cnblogs.com/Ninputer/" target="_blank">Haven</a> 2011-12-22 16:03 <a href="http://www.cnblogs.com/Ninputer/archive/2011/12/22/2120435.html#2276858#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>Re:.NET 4.0中的泛型协变和反变</title><link>http://www.cnblogs.com/Ninputer/archive/2011/12/14/1339058.html#2270037</link><dc:creator>小小白白</dc:creator><author>小小白白</author><pubDate>Wed, 14 Dec 2011 07:51:41 GMT</pubDate><guid>http://www.cnblogs.com/Ninputer/archive/2011/12/14/1339058.html#2270037</guid><description><![CDATA[@foxsummer
[code=csharp]

class Fax
{

}
class LaserPrinter : Fax
{

}
delegate Tresult Func&lt;in T,out Tresult&gt;(T arg);
class Program
{
static LaserPrinter teee(Fax i)
{
return new LaserPrinter();
}
static void Main()
{
Func&lt;Fax, LaserPrinter&gt; l = teee;
Func&lt;LaserPrinter, Fax&gt; f = l;//逆变：可以把子类型的参数传递给父类型的参数。LaserPrinter是Fax的子类。
//协变：可以把父类型的参数传递给子类型的参数。
Console.ReadKey();
}

}

[/code]
我是这样理解的，逆变和协变原理都是一样的，只不过是编译器根据关键字进行判断罢了。
[code=csharp]
private static void Main()
{
Func&lt;Fax, LaserPrinter&gt; l = new Func&lt;Fax, LaserPrinter&gt;(Program.teee);
Func&lt;LaserPrinter, Fax&gt; f = (Func&lt;LaserPrinter, Fax&gt;) l;
Console.ReadKey();//应该是这样工作的
}
[/code]
都是子类隐式转化为父类，用in关键字的逆变很好理解，out是标记返回，不也是从子类转换到父类的过程吗？
http://www.cnblogs.com/artech/archive/2011/01/13/variance.html<br><br><div align=right><a style="text-decoration:none;" href="http://www.cnblogs.com/Ninputer/" target="_blank">小小白白</a> 2011-12-14 15:51 <a href="http://www.cnblogs.com/Ninputer/archive/2011/12/14/1339058.html#2270037#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>Re:.NET 4.0中的泛型协变和反变</title><link>http://www.cnblogs.com/Ninputer/archive/2011/12/14/1339058.html#2270035</link><dc:creator>小小白白</dc:creator><author>小小白白</author><pubDate>Wed, 14 Dec 2011 07:50:50 GMT</pubDate><guid>http://www.cnblogs.com/Ninputer/archive/2011/12/14/1339058.html#2270035</guid><description><![CDATA[[code=csharp]

    class Fax
    {

    }
    class LaserPrinter : Fax
    {

    }
     delegate Tresult Func&lt;in T,out Tresult&gt;(T arg);
    class Program
    {
        static LaserPrinter teee(Fax i)
        {
            return new LaserPrinter();
        }
        static void Main()
        {
            Func&lt;Fax, LaserPrinter&gt; l = teee;
            Func&lt;LaserPrinter, Fax&gt; f = l;//逆变：可以把子类型的参数传递给父类型的参数。LaserPrinter是Fax的子类。
            //协变：可以把父类型的参数传递给子类型的参数。
          Console.ReadKey();
        }

    }

[/code]
我是这样理解的，逆变和协变原理都是一样的，只不过是编译器根据关键字进行判断罢了。
[code=csharp]
private static void Main()
{
    Func&lt;Fax, LaserPrinter&gt; l = new Func&lt;Fax, LaserPrinter&gt;(Program.teee);
    Func&lt;LaserPrinter, Fax&gt; f = (Func&lt;LaserPrinter, Fax&gt;) l;
    Console.ReadKey();//应该是这样工作的
}
[/code]
都是子类隐式转化为父类，用in关键字的逆变很好理解，out是标记返回，不也是从子类转换到父类的过程吗<br><br><div align=right><a style="text-decoration:none;" href="http://www.cnblogs.com/Ninputer/" target="_blank">小小白白</a> 2011-12-14 15:50 <a href="http://www.cnblogs.com/Ninputer/archive/2011/12/14/1339058.html#2270035#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>Re:Expression Tree上手指南 （一）</title><link>http://www.cnblogs.com/Ninputer/archive/2011/12/09/1555998.html#2265850</link><dc:creator>唐子慧</dc:creator><author>唐子慧</author><pubDate>Fri, 09 Dec 2011 03:55:34 GMT</pubDate><guid>http://www.cnblogs.com/Ninputer/archive/2011/12/09/1555998.html#2265850</guid><description><![CDATA[泪流满面的崇拜啊！<br><br><div align=right><a style="text-decoration:none;" href="http://www.cnblogs.com/Ninputer/" target="_blank">唐子慧</a> 2011-12-09 11:55 <a href="http://www.cnblogs.com/Ninputer/archive/2011/12/09/1555998.html#2265850#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>Re:Expression Tree上手指南 （一）</title><link>http://www.cnblogs.com/Ninputer/archive/2011/12/07/1555998.html#2264259</link><dc:creator>know@more</dc:creator><author>know@more</author><pubDate>Wed, 07 Dec 2011 09:12:49 GMT</pubDate><guid>http://www.cnblogs.com/Ninputer/archive/2011/12/07/1555998.html#2264259</guid><description><![CDATA[不错，好文！<br><br><div align=right><a style="text-decoration:none;" href="http://www.cnblogs.com/Ninputer/" target="_blank">know@more</a> 2011-12-07 17:12 <a href="http://www.cnblogs.com/Ninputer/archive/2011/12/07/1555998.html#2264259#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>Re:自己动手开发编译器（八）用Linq编写解析器组合子</title><link>http://www.cnblogs.com/Ninputer/archive/2011/12/05/2090645.html#2261727</link><dc:creator>深海沉</dc:creator><author>深海沉</author><pubDate>Mon, 05 Dec 2011 03:45:07 GMT</pubDate><guid>http://www.cnblogs.com/Ninputer/archive/2011/12/05/2090645.html#2261727</guid><description><![CDATA[有用<br><br><div align=right><a style="text-decoration:none;" href="http://www.cnblogs.com/Ninputer/" target="_blank">深海沉</a> 2011-12-05 11:45 <a href="http://www.cnblogs.com/Ninputer/archive/2011/12/05/2090645.html#2261727#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>Re:自己动手开发编译器（四）利用DFA转换表建立扫描器</title><link>http://www.cnblogs.com/Ninputer/archive/2011/11/27/2078671.html#2254703</link><dc:creator>君之蘭</dc:creator><author>君之蘭</author><pubDate>Sun, 27 Nov 2011 08:44:33 GMT</pubDate><guid>http://www.cnblogs.com/Ninputer/archive/2011/11/27/2078671.html#2254703</guid><description><![CDATA[看看下一节能看懂不，这节又废了<br><br><div align=right><a style="text-decoration:none;" href="http://www.cnblogs.com/Ninputer/" target="_blank">君之蘭</a> 2011-11-27 16:44 <a href="http://www.cnblogs.com/Ninputer/archive/2011/11/27/2078671.html#2254703#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item></channel></rss>
