Interface is used in the C# for declaring the function etc, which can be implement, in the various class. It is similar to the base class which can be inherit into the derived but it is multilayered and class inherit concept is single layer hence it is more accessible.
For Example-
using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace ConsoleApplication11 {
interface Interface1 {
void SampleMethod(); }
interface Interface2 {
void SampleMethod2(); }
class interfacedemo : Interface1, Interface2 {
public void SampleMethod()
{
Console.WriteLine("Sample Method");
}
public void SampleMethod2()
{
Console.WriteLine("SampleMethod2");
}
static void Main()
{
interfacedemo obj = new interfacedemo();
obj.SampleMethod();
obj.SampleMethod2();
Console.ReadLine();
} } }
Join MindStick Community
You need to log in or register to vote on answers or questions.
We use cookies to ensure you have the best browsing experience on our website. By using our site, you
acknowledge that you have read and understood our
Cookie Policy &
Privacy Policy.
Interface is used in the C# for declaring the function etc, which can be implement, in the various class. It is similar to the base class which can be inherit into the derived but it is multilayered and class inherit concept is single layer hence it is more accessible.
For Example-