Ray's playground

 

Item 39: Use Dynamic to Leverage the Runtime Type of Generic Type Parameters(Effective C#)

Cast<T>, like all generic methods, compiles with only limited knowledge of its type parameters. That can lead to generic methods not working the way you’d expect. The root cause is almost always that the generic method could not be made aware of particular functionality in the type representing the type parameters. When that happens, a little application of dynamic can enable runtime reflection to make matters right.

posted on 2011-02-25 23:56  Ray Z  阅读(235)  评论(0编辑  收藏  举报

导航