- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
What is a static polymorphism in C#?
Static Polymorphism is the linking of a function with an object during compile time is called static. It is also called static binding. C# provides two techniques to implement static polymorphism i.e. Function overloading and Operator overloading.
Let us learn about Function Overloading. You can have multiple definitions for the same function name in the same scope. The definition of the function must differ from each other by the types and/or the number of arguments in the argument list. You cannot overload function declarations that differ only by return type.
The following is the complete example −
Example
using System; namespace PolymorphismApplication { class Printdata { void print(int i) { Console.WriteLine("Printing int: {0}", i ); } void print(double f) { Console.WriteLine("Printing float: {0}" , f); } void print(string s) { Console.WriteLine("Printing string: {0}", s); } static void Main(string[] args) { Printdata p = new Printdata(); // Call print to print integer p.print(5); // Call print to print float p.print(500.263); // Call print to print string p.print("Hello C++"); Console.ReadKey(); } } }
- Related Articles
- What is the difference between static and dynamic polymorphism?
- What is polymorphism in C# ?
- What is Dynamic Polymorphism in C#?
- What is run time polymorphism in C#?
- What is compile time polymorphism in C#?
- What is a static class in C#?
- What is a static constructor in C#?
- What is the difference between compile time polymorphism and runtime polymorphism in java?
- What is a non-static class in C#?
- What is static binding in C#?
- Polymorphism example in C++
- What is a static storage class in C language?
- What is overriding and overloading under polymorphism in java?
- What is the lifetime of a static variable in a C++ function?
- What is runtime polymorphism or dynamic method overloading?

Advertisements