C# generics method invocation
- by Firat KÜÇÜK
Hi,
i have some polymorphic methods and i want to call via using an intermediate method.
Following class is the simplified version of my program.
class Program {
public class A {
}
public class B {
}
public class C {
}
public void SomeMethod(A value) {
Console.WriteLine("A value");
}
public void SomeMethod(B value) {
Console.WriteLine("B value");
}
public void SomeMethod(C value) {
Console.WriteLine("C value");
}
static void Main(string[] args) {
Program p = new Program();
// code block
p.IntermediateMethod<A>(new A());
p.IntermediateMethod<B>(new B());
p.IntermediateMethod<C>(new C());
}
public void IntermediateMethod<T>(T value) {
// code block
SomeMethod(value);
// code block
}
}