Thumb

What is interface?

1/11/2020 6:46:37 AM

An interface defined using the interface keyword. Interface looks like a class but when we create an interface then we can only define the method. Now when class are inherited then the class are responsible to implemented the method. Class are inherited only one class at a time but interface can inherit many interfaces at a time. Now Given bellow the interface example code:

using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using testForClass1;

namespace testFor
{
    public interface Emplyee : Teacher, Student
    {

    }
    public interface Teacher
    {
        void teacherName();

    }
    public interface Student
    {
        void studentName();
    }
    public class AllEmp : Emplyee
    {
        void Student.studentName()
        {
            Console.WriteLine("Farhan Sakib Jesy");
        }

        void Teacher.teacherName()
        {
            Console.WriteLine("Reza Karim");
        }

    }
    public class Program
    {

        static void Main(string[] args)
        {
            AllEmp obj = new AllEmp();

            Console.Read();
        }


    }
}