Question:

What are interfaces in C#? Write a program to demonstrate the usage of interface to implement multiple inherit

by  |  earlier

0 LIKES UnLike

What are interfaces in C#? Write a program to demonstrate the usage of interface to implement multiple inherit

 Tags:

   Report

3 ANSWERS


  1. Interfaces are classes that contain only abstract members. They're essentially used to ensure an inherited class implements certain functionality so that it can be reused robustly. This page has all the info you could need:

    http://www.codersource.net/csharp_tutori...


  2. Or, you could do your own homework....

  3. An interface in the C# programming language is an abstract type which is used to specify an interface (in the generic sense of the term) that classes must implement. An interface may never contain method definitions.

    Interfaces are used to encode similarities which classes of various types share, but do not necessarily constitute a class relationship. For instance, a human and a parrot can both whistle, however it would not make sense to represent Humans and Parrots as subclasses of a Whistler class, rather they would most likely be subclasses of an Animal class (likely with intermediate classes), but both would implement the Whistler interface.

    interface ISampleInterface

    {

        void SampleMethod();

    }

    //use---------------------------------...

    class ImplementationClass : ISampleInterface

    {

        // Explicit interface member implementation:

        void ISampleInterface.SampleMethod()

        {

            // Method implementation.

        }

        static void Main()

        {

            // Declare an interface instance.

            ISampleInterface obj = new ImplementationClass();

            // Call the member.

            obj.SampleMethod();

        }

    }

Question Stats

Latest activity: earlier.
This question has 3 answers.

BECOME A GUIDE

Share your knowledge and help people by answering questions.