Write a C# program to demonstrate the multiple inheritances

Write a C# program to demonstrate the multiple inheritances

Write a C# program to demonstrate the multiple inheritance

Object:

Write a C# program to demonstrates the multiple inheritances \ Multilevel inheritance in c# with example C# Projects with Source Code

Code:

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

namespace _22sep

{

    interface IName

    {

        void displayname(string a);

    }

    interface ILocation

    {

        void displaylocation(string b);

    }

    interface IAge

    {

        void displayage(string c);

    }

    class user: IName, ILocation, IAge

    {

        public void displayname(string a)

        {

            Console.WriteLine(“Name : “+a);

        }

        public void displaylocation(string b)

        {

            Console.WriteLine(“Location : ” + b);

        }

        public void displayage(string c)

        {

            Console.WriteLine(“Age : ” + c);

        }

    }

    class Program

    {

        static void Main(string[] args)

        {

            user u = new user();

            u.displayname(“James”);

            u.displaylocation(“Miami”);

            u.displayage (“20”);

            Console.ReadKey();

        }

    }

}

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

namespace _22sep
{
    interface IName
    {
        void displayname(string a);
    }
    interface ILocation
    {
        void displaylocation(string b);
    }
    interface IAge
    {
        void displayage(string c);
    }
    class user : IName, ILocation, IAge
    {
        public void displayname(string a)
        {
            Console.WriteLine("Name : "+a);
        }
        public void displaylocation(string b)
        {
            Console.WriteLine("Location : " + b);
        }
        public void displayage(string c)
        {
            Console.WriteLine("Age : " + c);
        }
    }
    class Program
    {
        static void Main(string[] args)
        {
            user u = new user();
            u.displayname("James");
            u.displaylocation("Miami");
            u.displayage ("20");
            Console.ReadKey();
        }
    }
}

 

Output:

Write a C# program to demonstrate the multiple inheritances

Another C# Program: C# Program Calculating the Area of a Rectangle

Another C# Program: C# Program that Subtracts two user-defined numbers

Another C# Program: C# Program Create a class student with a data members name and calculate marks and percentage.

Another C# Program: C# program to count vowels in a string

Another Program: Write a C# program to create a static function factorial and calculate factorial of the number.

Another Program: Write a C# program that reads two arrays and checks whether they are equal.

Another Program: Develop a C# app that will determine the gross pay for each of three employees

3 thoughts on “Write a C# program to demonstrate the multiple inheritances”

  1. Pingback: C# Program that read array display the smallest integer and sort the array in ascending order by using Array.Sort method.

  2. Pingback: C# windows form application that converts the temperature from Fahrenheit to Celsius

  3. Pingback: Top 20 C# programs examples in 2021

Leave a Comment

Your email address will not be published. Required fields are marked *