﻿<?xml version="1.0" encoding="utf-8"?><rss version="2.0"><channel><title>Ayende @ Rahien</title><link>http://ayende.com</link><description>Ayende @ Rahien</description><copyright>Copyright (C) Ayende Rahien  2004 - 2021 (c) 2026</copyright><ttl>60</ttl><item><title>Doug Mayer commented on Generics Challage: Assert Return Types Matches</title><description>Wow, this is a good one.  The method's return type will always be T, because at runtime it's resolved from System.RuntimeType.
  
  
The only way I'd know of is to also have a LastReturnType static field on Dog and set it to typeof(T) in BarkInvocation&lt;T&gt;.Bark()... which I'm sure there's a reason you're not already doing (I know I hate to add what I feel are more fields that aren't required).
  
  
@Weex,
  
If you do a test as I mention above, you'll see that just calling
  
typeof(IList&lt;string&gt;).IsInstanceOf(new List&lt;string&gt;());
  
will return true.
</description><link>http://ayende.com/2132/generics-challage-assert-return-types-matches#comment2</link><guid>http://ayende.com/2132/generics-challage-assert-return-types-matches#comment2</guid><pubDate>Fri, 23 Feb 2007 14:22:14 GMT</pubDate></item><item><title>Weex commented on Generics Challage: Assert Return Types Matches</title><description>IList&lt;string&gt; is not an instance of List&lt;string&gt;, isn't it? 
</description><link>http://ayende.com/2132/generics-challage-assert-return-types-matches#comment1</link><guid>http://ayende.com/2132/generics-challage-assert-return-types-matches#comment1</guid><pubDate>Fri, 23 Feb 2007 13:37:54 GMT</pubDate></item></channel></rss>