c# polymorphism without method overloading (for a webmethod)
<p>Okay, so I realised after writing some overloaded methods that webmethods can't be overloaded (by realised I mean VS  threw a paddy and wouldn't allow me to update the service references). I have tried to get around that like this:</p>

<pre><code>    public string DoPing&lt;T&gt;(T IP)
    {

        if (typeof(T) == typeof(string))
        { 
            return DoPingString(IP);
        }
        if (typeof(T) == typeof(IPAddress))
        {
            return DoPingIP(IP);
        }
        throw new Exception("Programmer Error");
    }
</code></pre>

<p>But I'm getting a cannot convert from T to string/Ipadress error when I call the respective (renamed) methods. 
Can someone explain why it doesn't work, and possibly either fix it or give me an alternate solution?
Thanks in advance.</p>

<p>Edit: Good point, generics are probably overkill (I tried for another solution and failed before trying this).
DoPingString(string String) and DoPingIP(IPAdress Address) are the signatures.
I will give the tick to the closest answer tomorrow. I solved the problem in a separate way.</p>
