<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	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/"
		>
<channel>
	<title>Comments on: C# Overloaded Methods with Inherited Arguments</title>
	<atom:link href="http://www.csharp411.com/c-overloaded-methods-with-inherited-arguments/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.csharp411.com/c-overloaded-methods-with-inherited-arguments/</link>
	<description>C# Development</description>
	<lastBuildDate>Fri, 03 Feb 2012 11:14:43 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
	<item>
		<title>By: Coder</title>
		<link>http://www.csharp411.com/c-overloaded-methods-with-inherited-arguments/#comment-842</link>
		<dc:creator>Coder</dc:creator>
		<pubDate>Wed, 24 Nov 2010 21:14:43 +0000</pubDate>
		<guid isPermaLink="false">http://www.csharp411.com/c-overloaded-methods-with-inherited-arguments/#comment-842</guid>
		<description>Hi,

In case 5 of your example:

Base b2 = new Derived();

leads to:
Do( Base ) on Derived

Is it possible to get b2 handled by
public void Do( Derived d )
rather than by
public void Do( Base d )
?

I have a situation where I have to access the Methods class through a helper method: eg:

using System;
using System.Collections.Generic;
using System.Text;

namespace TestCon
{

class Program
    {
        static void Main( string[] args )
        {
            object o1 = new object();
            object o2 = new Base();
            object o3 = new Derived();
            Base b1 = new Base();
            Base b2 = new Derived();
            Derived d1 = new Derived();
            DateTime t1 = new DateTime(); 

            Methods methods = new Methods();
            PreMethods prem = new PreMethods();
            methods.Do( o1 );
            methods.Do( o2 );
            methods.Do( o3 );
            methods.Do( b1 );
            methods.Do( b2 );

            prem.Do(d1); // &lt;---

            methods.Do( d1 );
            methods.Do( t1 ); 

            Console.ReadLine();
        }
    }

    class PreMethods
    {
        Methods methods = new Methods();

        public void Do(Base o)
        {
            methods.Do(o); 
        }
    }

    class Methods
    {
        public void Do( object o )
        {
            Write( &quot;object&quot;, o );
        }
        public void Do( Base b )
        {
            Write( &quot;Base&quot;, b );
        }
        public void Do( Derived d )
        {
            Write( &quot;Derived&quot;, d );
        }
        private void Write( string method, object obj )
        {
            Console.WriteLine( &quot;Do( {0} ) on {1}&quot;, method, obj.GetType().Name );
        }
    }
    class Base { }
    class Derived : Base { }


}</description>
		<content:encoded><![CDATA[<p>Hi,</p>
<p>In case 5 of your example:</p>
<p>Base b2 = new Derived();</p>
<p>leads to:<br />
Do( Base ) on Derived</p>
<p>Is it possible to get b2 handled by<br />
public void Do( Derived d )<br />
rather than by<br />
public void Do( Base d )<br />
?</p>
<p>I have a situation where I have to access the Methods class through a helper method: eg:</p>
<p>using System;<br />
using System.Collections.Generic;<br />
using System.Text;</p>
<p>namespace TestCon<br />
{</p>
<p>class Program<br />
    {<br />
        static void Main( string[] args )<br />
        {<br />
            object o1 = new object();<br />
            object o2 = new Base();<br />
            object o3 = new Derived();<br />
            Base b1 = new Base();<br />
            Base b2 = new Derived();<br />
            Derived d1 = new Derived();<br />
            DateTime t1 = new DateTime(); </p>
<p>            Methods methods = new Methods();<br />
            PreMethods prem = new PreMethods();<br />
            methods.Do( o1 );<br />
            methods.Do( o2 );<br />
            methods.Do( o3 );<br />
            methods.Do( b1 );<br />
            methods.Do( b2 );</p>
<p>            prem.Do(d1); // &lt;&#8212;</p>
<p>            methods.Do( d1 );<br />
            methods.Do( t1 ); </p>
<p>            Console.ReadLine();<br />
        }<br />
    }</p>
<p>    class PreMethods<br />
    {<br />
        Methods methods = new Methods();</p>
<p>        public void Do(Base o)<br />
        {<br />
            methods.Do(o);<br />
        }<br />
    }</p>
<p>    class Methods<br />
    {<br />
        public void Do( object o )<br />
        {<br />
            Write( &quot;object&quot;, o );<br />
        }<br />
        public void Do( Base b )<br />
        {<br />
            Write( &quot;Base&quot;, b );<br />
        }<br />
        public void Do( Derived d )<br />
        {<br />
            Write( &quot;Derived&quot;, d );<br />
        }<br />
        private void Write( string method, object obj )<br />
        {<br />
            Console.WriteLine( &quot;Do( {0} ) on {1}&quot;, method, obj.GetType().Name );<br />
        }<br />
    }<br />
    class Base { }<br />
    class Derived : Base { }</p>
<p>}</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: eFforneinvara</title>
		<link>http://www.csharp411.com/c-overloaded-methods-with-inherited-arguments/#comment-841</link>
		<dc:creator>eFforneinvara</dc:creator>
		<pubDate>Sun, 04 Jan 2009 06:16:13 +0000</pubDate>
		<guid isPermaLink="false">http://www.csharp411.com/c-overloaded-methods-with-inherited-arguments/#comment-841</guid>
		<description>There are 5 houses in five different colors
In each house lives a different nationality.
These 5 owners drink a certain beverage, smoke a certain brand of cigar and keep a certain pet.
No owners have the same pet, smoke the same brand of cigar, or drink the same beverage.

The CLUES:

The Brit lives in the Red house.
The Swede keeps dogs as pets.
The Dane Drinks tea.
The Green House is on the left of the White House.
The Green House&#039;s owner drinks coffee.
The person who smokes Pall Mall rears birds.
The owner of the yellow house smokes Dunhill.
The man in the center house drinks milk.
The Norwegian lives in the first house.
The man who smokes Blends lives next to the one who keeps cats
The man who keeps horses lives next to the man who smokes Dunhill.
The man who smokes Blue Master drinks beer.
The German smokes Prince.
The Norwegian lives next to the Blue House.
The man who smokes Blends has a neighbor who drinks water.
The QUESTION:

Who owns the fish?</description>
		<content:encoded><![CDATA[<p>There are 5 houses in five different colors<br />
In each house lives a different nationality.<br />
These 5 owners drink a certain beverage, smoke a certain brand of cigar and keep a certain pet.<br />
No owners have the same pet, smoke the same brand of cigar, or drink the same beverage.</p>
<p>The CLUES:</p>
<p>The Brit lives in the Red house.<br />
The Swede keeps dogs as pets.<br />
The Dane Drinks tea.<br />
The Green House is on the left of the White House.<br />
The Green House&#8217;s owner drinks coffee.<br />
The person who smokes Pall Mall rears birds.<br />
The owner of the yellow house smokes Dunhill.<br />
The man in the center house drinks milk.<br />
The Norwegian lives in the first house.<br />
The man who smokes Blends lives next to the one who keeps cats<br />
The man who keeps horses lives next to the man who smokes Dunhill.<br />
The man who smokes Blue Master drinks beer.<br />
The German smokes Prince.<br />
The Norwegian lives next to the Blue House.<br />
The man who smokes Blends has a neighbor who drinks water.<br />
The QUESTION:</p>
<p>Who owns the fish?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: GreniliedeRed</title>
		<link>http://www.csharp411.com/c-overloaded-methods-with-inherited-arguments/#comment-840</link>
		<dc:creator>GreniliedeRed</dc:creator>
		<pubDate>Sat, 20 Dec 2008 03:14:18 +0000</pubDate>
		<guid isPermaLink="false">http://www.csharp411.com/c-overloaded-methods-with-inherited-arguments/#comment-840</guid>
		<description>Thak you for the news</description>
		<content:encoded><![CDATA[<p>Thak you for the news</p>
]]></content:encoded>
	</item>
</channel>
</rss>

