C# Program to Illustrate Polymorphism1 min read

This article to illustrate the use of Polymorphism in C# shows fro three different data types.

Write a C# Program to illustrate the use of Polymorphism.

In the following program, we create an object for Polymorphism Class, and under this Class, we create three functions of the same name print but varying in argument data types. Now we call the print function by passing the three different values(different data types). We see that despite having the same function name(print), we can still print for three different data types as shown in the program.

C# Program to Illustrate Polymorphism

The output of Polymorphism in C#.

C# Program to Swap two Numbers