Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public interface IExampleInterface<in TIn, out TOut>
- {
- public TOut MyMethod(TIn param);
- }
- public class MyExampleInheritor : IExampleInterface<B, B>
- {
- public B MyMethod(B param)
- {
- Debug.LogWarning($"Param is {param}");
- return (C)param;
- }
- }
- public class UseExample
- {
- public UseExample()
- {
- var inst = new MyExampleInheritor();
- var result = (C) inst.MyMethod(new D());
- Debug.LogWarning($"Return is {result}");
- }
- }
- public class A
- {
- public override string ToString()
- {
- return $"class A";
- }
- }
- public class B : A
- {
- public override string ToString()
- {
- return $"class B";
- }
- }
- public class C : B
- {
- public override string ToString()
- {
- return $"class C";
- }
- }
- public class D : C
- {
- public override string ToString()
- {
- return $"class D";
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement