C# Multiple Inheritance Interfaces Tutorial with Examples

C# Multiple Inheritance Interfaces Tutorial with Examples

Today, We want to share with you C# Multiple Inheritance Interfaces Tutorial with Examples.In this post we will show you Multiple Inheritance In C# Using Interfaces, hear for C# Multiple Inheritance with Interface we will give you demo and example for implement.
In this post, we will learn about Multiple Inheritance in C# with an example.

Introduction: Multiple Inheritance In C# Using Interfaces

In this post, we will learn about Multiple Inheritance In C# Using Interfaces with an example.

Now in this post, I will explain how to achieve Multiple Inheritance In C# Using Interfaces with appropriate example.Here I will explain simple mathematical operation program demonstrating how multiple inheritances can be achieved in C# using Interface Concept.

Now create Console Application in Visual Studio and write below lines of code in it.

using System;
using System.Collections;

namespace ConsoleDemo
{   
    class Program
    {
        interface Operation1
        {
            int AddNumber(int no1, int no2);
        }
        interface Operation2
        {
            int SubtractNumber(int no1, int no2);
        }
        interface Operation3
        {
            int MultiplyNumber(int no1, int no2);
        }
        interface Operation4
        {
            int DivideNumber(int no1, int no2);
        }

        class Calculation : Operation1, Operation2, Operation3, Operation4
        {
            public int result1;
            public int AddNumber(int a, int b)
            {
                return result1 = a + b;
            }
            public int result2;
            public int SubtractNumber(int x, int y)
            {
                return result2 = x - y;
            }
            public int result3;
            public int MultiplyNumber(int r, int s)
            {
                return result3 = r * s;
            }
            public int result4;
            public int DivideNumber(int c, int d)
            {
                return result4 = c / d;
            }

            class Program
            {
                static void Main(string[] args)
                {
                    Calculation c = new Calculation();
                    c.AddNumber(15, 30);
                    c.SubtractNumber(200, 150);
                    c.MultiplyNumber(15, 5);
                    c.DivideNumber(50, 10);
                    Console.WriteLine("Multiple Inheritance concept Using Interfaces :\n ");
                    Console.WriteLine("Addition: " + c.result1);
                    Console.WriteLine("Substraction: " + c.result2);
                    Console.WriteLine("Multiplication :" + c.result3);
                    Console.WriteLine("Division: " + c.result4);
                    Console.ReadKey();
                }
            }
        }

    }   
}

Read :

Summary

You can also read about AngularJS, ASP.NET, VueJs, PHP.

I hope you get an idea about Multiple Inheritance In C# Using Interfaces.
I would like to have feedback on my Pakainfo.com blog.
Your valuable feedback, question, or comments about this article are always welcome.
If you enjoyed and liked this post, don’t forget to share.

Leave a Comment