This post originated from an RSS feed registered with .NET Buzz
by Brad Wilson.
Original Post: IanG on Latent Typing
Feed Title: The .NET Guy
Feed URL: /error.aspx?aspxerrorpath=/dotnetguy/Rss.aspx
Feed Description: A personal blog about technology in general, .NET in specific, and when all else fails, the real world.
IanG goes to town on latent typing (which he doesn't think I'm talking about), and compares C++ to C# to Python. Obviously, I like the Python example the best, because it is the most power with the least amount of cruft.
Ian points out a way to get the type of thing I want using reflection:
public static void CallDraw<T>(T something)
{
something.GetType().GetMethod("Draw").Invoke(something, null);
}
I feel like I have to point out that templates aren't even necessary here. You can do this, today, in .NET 1.1:
public static void CallDraw(object something)
{
something.GetType().GetMethod("Draw").Invoke(something, null);
}
Nice read, though. He really hits all the points, and talks about why things are done the way they're done. It doesn't make me any happier, but I'm willing to use a different phrase than "latent typing" if that makes Ian happy. :)
The opinions expressed herein are solely those of Brad Wilson, and not meant as an endorsement of or by any other individuals or groups. This syndication is provided for the private, personal use of individuals. Unauthorized commercial reproduction is strictly prohibited.