The following program outputs:
in Parse, type='System.Int32'
in Parse<T>, T='System.Object'
Is this behavior intended and if yes, why ? I would expect a compile error.
using System;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
object value;
Parser.TryParse(typeof(int), "1", out value);
Console.ReadLine();
}
}
class Parser
{
public static bool TryParse<T>(string input, out T value)
{
Console.WriteLine("in Parse<T>, T='{0}'", typeof(T));
value = default(T);
return true;
}
public static bool TryParse(Type type, string input, out object value)
{
Console.WriteLine("in Parse, type='{0}'", type);
return TryParse(input, out value);
}
}
}
--
Sébastien
www.sebastienlorion.com
===================================
This list is hosted by DevelopMentor® http://www.develop.com
View archives and manage your subscription(s) at http://discuss.develop.com