18/06/28 05:25:02.37 mpKH796a0.net
>>331
レスどうもです!下のようにして上手くいきました
こうなってくるとm1に対する方法はたまたま問題が起きないだけで
m2やm3の方法のほうが望ましいように思えてきましたがそういう認識であってますか?
==
using System.Runtime.CompilerServices;
class B<T> { public void M() { } }
class C1 : B<int> { }
class C2 : B<string> { }
class C3 : B<int> { }
class Program
{
static void Main(string[] args)
{
var m1 = typeof(C1).GetMethod("M").MethodHandle;
var m2 = typeof(C2).GetMethod("M").MethodHandle;
var m3 = typeof(C3).GetMethod("M").MethodHandle;
RuntimeHelpers.PrepareMethod(m1); // 問題なし
RuntimeHelpers.PrepareMethod(m2, new[] { typeof(string).TypeHandle }); // 問題なし
RuntimeHelpers.PrepareMethod(m3, new[] { typeof(int).TypeHandle }); // 問題なし
}
}
==