ものがたり(旧)

atsushieno.hatenablog.com に続く

thisは絶対にgenerics parameter typeではない

cscでも出ましたけど


using System.Collections.Generic;

class Test
{
public IEnumerable Foo (IEnumerator e)
{
List l = new List ();
if (this is T)
l.Add ((T) this);
return l;
}
}

generic-t.cs(9,11): error CS0030: Cannot convert type 'Test' to 'T'
ですって。

追記: 9行目にあるのはisではなくてexplicit conversionじゃん…以下リンク先参照。

そんなわけで面倒になったんで一時中断。まあ、XOMだし。