ふらっとC#,C♯,C#(初心者用) Part55
■ このスレッドは過去ログ倉庫に格納されています
0762デフォルトの名無しさん
2010/02/21(日) 01:10:44static void Main(string[] args)
{
var b = new B();
var c = new C();
CommandFunc(1, 2, b, a => Func1(b as B));
CommandFunc(1, 2, c, a => Func2(c as C));
}
delegate void dele(A a);
static void CommandFunc(int para1,int para2,A a, dele callFunc)
{
// Func1かFunc2を実行したい
callFunc(a);
}
static void Func1(B b) { b.MethodB(); }
static void Func2(C c) { c.MethodC(); }
}
class A { }
class B : A { public void MethodB() { Console.WriteLine("Bだよ"); } }
class C : A { public void MethodC() { Console.WriteLine("Cだよ"); } }
微妙すぎる
■ このスレッドは過去ログ倉庫に格納されています