What is an Interface
Multiple inheritence in .Net
Microsoft .Net does not support multiple inheritance. The biggest problem with multiple inheritance is that it allows for ambiguity when the compiler needs to find the correct implementation of a virtual method. Microsoft introduce Interface as a solution for multiple inheritance. Microsoft .NET allows you to have a single class in the list of parents , therefore supporting single inheritance, but you are free to implement as many interfaces as you wish.
Interface in C#
An interface is a specification for a set of class members, not an implementation. An Interface is a reference type and it contains only abstract members such as Events, Methods, Properties etc. It contain only declaration for its members and implementation defined as separate entities from classes. It can't contain constants, data fields, constructors, destructors and static members and all the member declarations inside interface are implicitly public.
You can think of an interface as an abstract class that contains only pure virtual functions.The implementation of the methods is done in the class that implements the interface.
Difference between the Interface and Class
A Class is a full body entity with members, methods along with there definition and implementation. An Interface is just a set of definition that you must implement in your Class inheriting that Interface. More about..... Class and Interface
- C# Frequently Asked Questions - 1
- C# Frequently Asked Questions - 2
- C# Frequently Asked Questions - 3
- Difference between a Debug and Release build
- Difference between normal DLL and .Net DLL
- Difference between Abstract Class and Interface
- Difference between a thread and a process
- What is .Net Delegates
- Differences between a control and a component
- Differences between Stack and Heap
- What is .Net Reflection
- Globalization and Localization
- What is .Net serialization
- Difference between web service and .net remoting
- Difference between managed and unmanaged code
- Difference between Shallow copy and Deep copy
- Use of System.Environment Class
- What is the difference between private and shared assembly?
- Does the .NET have in-built support for serialization?
- How to properly stop the Thread in C#?
- Why are there five tracing levels in System.Diagnostics.TraceSwitcher?
- Why is XmlSerializer so slow?
- How many types of Jit Compilers?