0

hi..

im trying to do some practice on interfaces when i found this problem. i just want to know that if i have 2 interfaces with the same method names. i can implement this 2 same method names in a derived class but i just don understand how to call those method names in a main class.im attaching my code also...pl check & let me know that how can i call a specific method from the derived class..

class Program
    {
        #region Test
        public interface ITest
        {
            void Show();
             int Show(int x);
        }
       public interface ITest2
        {
            void Show();
            int Show(int x);
            void Show2();
        }
              class test : ITest2,ITest
        {
            public override void  Showx()
            {
 	        
                Console.WriteLine("In Base Show");
            }
           public void Show()
            {
                Console.WriteLine("In Itest.Show()");
            }

            void ITest2.Show()
            {
                Console.WriteLine("In Itest2.Show()");
            }
            void ITest.Show()
            {
                Console.WriteLine("In Itest.Show()");
            }
            public int Show(int x)
            {
                Console.WriteLine("\nThis is the value of x "+(++x));
                return x;
            }
            public void Show2()
            {
                Console.WriteLine("In show2");
            }
        }
        #endregion

        static void Main(string[] args)
        {
            test t = new test();
            t.Show();
            Console.ReadLine();
        }

as u can see in the code that i have implemented both the Show() methods. if i want to call a method from ITest2, then what steps do i need to take?coz i get the output with the show() from ITest interface & not from the ITest2 interface.
Please do let me know soon.

2
Contributors
1
Reply
2
Views
7 Years
Discussion Span
Last Post by __avd
This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.