

- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How do you make code reusable in C#?
To make code reusable in C#, use Interfaces. Interfaces define properties, methods, and events, which are the members of the interface. Interfaces contain only the declaration of the members. It is the responsibility of the deriving class to define the members. It often helps in providing a standard structure that the deriving classes would follow.
For example, Shape Interface −
public interface IShape { void display(); }
Above we have declared an Interface Shape. You can notice that it begins with a capital “I”. It is a common convention that interfaces names begin with “I”.
We have not added an access specifier above since interface members are public by default.
In real applications, Polymorphism is key for code reuse. Interfaces are flexible because if you use interfaces, then with its help you can pass anything that implements that Interface.
- Related Questions & Answers
- How do you make a list iterator in Java?
- How do you make a shallow copy of a list in Java?
- What will you do to make your man go crazy in love with you?
- How do you make a string in PHP with a backslash in it?
- How can you make people listen to you?
- How do you make a separation and divorce as amicable as possible?
- How do you make Selenium 2.0 wait for the page to load?
- How do you run your own code alongside Tkinter's event loop?
- How do you make a button that adds text in HTML <input>?
- How do you earn bitcoins?
- How to deal with reusable components in Selenium Java?
- How do cybercriminals make money?
- How do you know when someone really loves you?
- How do you conduct function Testing?
- How do you measure Network Performance?