WHAT IS A BASIC CONCEPT OF INTERFACE

Jonas Stuart

Total Post:26

Points:130
Posted by  Jonas Stuart
C# 
C#
 297  View(s)
Ratings:
Rate this:
  1. Jonas Stuart

    Post:26

    Points:130
    What is a basic concept of Interface

    Interface is used in the C# for declaring the function etc, which can be implement, in the various  class. It is similar to the base class which can be inherit into the derived but it is multilayered and class inherit concept is single layer hence it is more accessible.

    For Example-

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
     
    namespace ConsoleApplication11
    {
        interface Interface1
        {
            void SampleMethod();
        }
        interface Interface2
        {
            void SampleMethod2();
        }
     
        class interfacedemo : Interface1, Interface2
        {
     
            public void SampleMethod()
            {
                Console.WriteLine("Sample Method");
            }
            public void SampleMethod2()
            {
                Console.WriteLine("SampleMethod2");
            }
            static void Main()
            {
                interfacedemo obj = new interfacedemo();
                obj.SampleMethod();
                obj.SampleMethod2();
                Console.ReadLine();
            }
        }
    }

Answer

NEWSLETTER

Enter your email address here always to be updated. We promise not to spam!