<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Mingbo &#187; 隐藏函数</title>
	<atom:link href="http://shao.mingbo.de/tag/%e9%9a%90%e8%97%8f%e5%87%bd%e6%95%b0/feed/" rel="self" type="application/rss+xml" />
	<link>http://shao.mingbo.de</link>
	<description>包括教育技术，编程，互联网等方面的文章及随想。</description>
	<lastBuildDate>Thu, 26 Aug 2010 02:57:15 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=abc</generator>
		<item>
		<title>cSharp继承的学习笔记-PartOne</title>
		<link>http://shao.mingbo.de/2009/11/28/inheritance-notes-of-csharp-part-one/</link>
		<comments>http://shao.mingbo.de/2009/11/28/inheritance-notes-of-csharp-part-one/#comments</comments>
		<pubDate>Fri, 27 Nov 2009 16:35:28 +0000</pubDate>
		<dc:creator>邵 明博</dc:creator>
				<category><![CDATA[.NET 编程]]></category>
		<category><![CDATA[csharp]]></category>
		<category><![CDATA[myNote]]></category>
		<category><![CDATA[继承]]></category>
		<category><![CDATA[隐藏函数]]></category>

		<guid isPermaLink="false">http://shao.mingbo.de/?p=289</guid>
		<description><![CDATA[在昨天的笔记中提到“结构本身不支持继承”，实际上有些武断。结构不能建立类型层次，但结构可以实现接口。 c# 的隐藏方法，这一块一直都觉得挺晦涩难懂。实际上，是没有理解出，它和虚函数之间的关系。下面以一个例子说明： static void Main(string[] args) { testClass t = new testClass2(); t.myMethod(); t.my(); } class testClass { public void myMethod() { Console.WriteLine("In base method"); } public virtual void my() { Console.WriteLine("Virtual in base"); } } class testClass2 : testClass { public new void myMethod() { Console.WriteLine("In child method"); } public override void my() [...]]]></description>
			<content:encoded><![CDATA[<p>在昨天的笔记中提到“结构本身不支持继承”，实际上有些武断。结构不能建立类型层次，但结构可以实现接口。</p>
<p><strong>c# 的隐藏方法</strong>，这一块一直都觉得挺晦涩难懂。实际上，是没有理解出，它和虚函数之间的关系。下面以一个例子说明：</p>
<pre name="code" class="c-sharp">        static void Main(string[] args)
        {

            testClass t = new testClass2();
            t.myMethod();
            t.my();
        }

        class testClass
        {
            public void myMethod()
            {
                Console.WriteLine("In base method");
            }

            public virtual void my()
            {
                Console.WriteLine("Virtual in base");
            }

        }

        class testClass2 : testClass
        {
            public new void myMethod()
            {
                Console.WriteLine("In child method");
            }

            public override void my()
            {
                Console.WriteLine("override in derived");
            }
        }</pre>
<ul>
<li>有没有new 这个显式的声明隐藏方法的形式，不是必须的。如果没有，则编译器会还会警告你，它会默认的按照隐藏基类的方法执行。</li>
<li>从编译结果看来，隐藏函数和虚函数的区别是，override 虚函数后，用基类引用子类的实例并调用该函数，会显示其多态性。但，隐藏函数则会直接显示其基类中的相关函数。</li>
</ul>
<p>&#8212;&#8212;&#8212;&#8212;以下与笔记无关&#8212;&#8212;&#8212;&#8212;</p>
<p>最近这两天的效率实在是低。昨天是相当于一整天只更新了一篇关于《<a href="http://shao.mingbo.de/2009/11/26/object-and-class-in-csharp/" target="_blank">对象和类</a>》的日志，而今天只看了<strong>继承</strong>这一章的1/6 的内容。持续的低迷，精神状态是一方面的原因——午睡的时间给耽误了，加上早先的几天的熬夜，显得这几天看书效率低了好几个档次。另外，今天下午还是铁着心，跑出去买了一个<a href="http://www.pny.com.cn/news_1.asp?ID=110" target="_blank">PNY 的浪漫紫罗双子盘</a>+<a href="http://www.onda.cn/pro/product/product.jsp?Id=14412&amp;PT=2" target="_blank">一个昂达的方块糖P3 </a>，很心疼的说。提起U盘，那真是一头包的，月头才买不久的Sandisk 就神不知鬼不觉的不见了；提起这次买的P3，让我想起04 年那会，昂达刚出第一款<a href="http://www.onda.cn/pro/product/product.jsp?Id=4305&amp;PT=2" target="_blank">vx505</a> 时，我就买了。</p>
<h3  class="related_post_title">相关文章</h3><ul class="related_post"><li>2009年11月28日 -- <a href="http://shao.mingbo.de/2009/11/28/inheritance-notes-of-csharp-part-two/" title="cSharp继承的学习笔记-PartTwo">cSharp继承的学习笔记-PartTwo</a></li><li>2009年12月22日 -- <a href="http://shao.mingbo.de/2009/12/22/how-to-use-backgroundworker-in-csharp/" title="cSharp中BackgroundWorker的用法">cSharp中BackgroundWorker的用法</a></li><li>2009年12月21日 -- <a href="http://shao.mingbo.de/2009/12/21/synchronize-class-design-in-csharp/" title="cSharp中同步类的设计">cSharp中同步类的设计</a></li><li>2009年12月20日 -- <a href="http://shao.mingbo.de/2009/12/20/paralize-thread-in-charp/" title="cSharp中给线程传递参数">cSharp中给线程传递参数</a></li><li>2009年12月19日 -- <a href="http://shao.mingbo.de/2009/12/19/asynchronous-delegate-in-csharp/" title="cSharp中异步委托的笔记">cSharp中异步委托的笔记</a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://shao.mingbo.de/2009/11/28/inheritance-notes-of-csharp-part-one/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
