<=?Utf-8?B?RWQgQ2hhcGVs?= <Ed Chapel@discussions.microsoft.com>>
wrote:
> In the following code (over-simplified, of course), the generic method calls
> itself recursively, quickly resulting in a StackOverflowException:
[quoted text clipped - 12 lines]
> (lacking the 'generic' brackets) indicated the non-generic method would be
> called. Why does this behave this way?
It's using type inference to call the generic version without
explicitly stating the type involved. T is more specific than object,
hence the compiler is choosing the generic version over the non-generic
version.
If you cast value to object, your call will go to the non-generic
version.
You'd have to look at the specs in detail for the exact steps the
compiler will take.

Signature
Jon Skeet - <skeet@pobox.com>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too
Ed Chapel - 28 Mar 2006 19:10 GMT
That answers my question. Thank you! I learn something new everyday.
Ed
> <=?Utf-8?B?RWQgQ2hhcGVs?= <Ed Chapel@discussions.microsoft.com>>
> wrote:
[quoted text clipped - 25 lines]
> You'd have to look at the specs in detail for the exact steps the
> compiler will take.