How can i know from which interface the method is calling?
-
namespace MYConsoleApplication
{
class Program
{
static void Main(string[] args)
{int x = 3; int y = 2; x= (x==y++)?x+y:x-y; A ObjA = new A(); ObjA.M1(); } } interface Inf1 { void M1(); void M2(); } interface Inf2 { void M1(); } class A: Inf1,Inf2 { public void M1() { Console.Write("test"); } public void M2() { Console.Write("test2"); } }
}
From the above code ..how can i know from which interface the method M1() is overriding in Class A. Please let me know..if this is the case where tow interfaces contains same method..
G. Satish
-
namespace MYConsoleApplication
{
class Program
{
static void Main(string[] args)
{int x = 3; int y = 2; x= (x==y++)?x+y:x-y; A ObjA = new A(); ObjA.M1(); } } interface Inf1 { void M1(); void M2(); } interface Inf2 { void M1(); } class A: Inf1,Inf2 { public void M1() { Console.Write("test"); } public void M2() { Console.Write("test2"); } }
}
From the above code ..how can i know from which interface the method M1() is overriding in Class A. Please let me know..if this is the case where tow interfaces contains same method..
G. Satish
-
namespace MYConsoleApplication
{
class Program
{
static void Main(string[] args)
{int x = 3; int y = 2; x= (x==y++)?x+y:x-y; A ObjA = new A(); ObjA.M1(); } } interface Inf1 { void M1(); void M2(); } interface Inf2 { void M1(); } class A: Inf1,Inf2 { public void M1() { Console.Write("test"); } public void M2() { Console.Write("test2"); } }
}
From the above code ..how can i know from which interface the method M1() is overriding in Class A. Please let me know..if this is the case where tow interfaces contains same method..
G. Satish
It is not overriding M1, it is implementing it for BOTH interfaces. If you wanted, you could also explicitly implement it for each interface (so that casting it as Inf1 and calling M1 will do something different than casting it as Inf2 and calling M1).