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.

>i want to call a method from ITest2

ITest2 a=new test();
a.Show();
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.