What is Interface? Explain with an example.

Answer Posted / srinivasa reddy

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace InterfaceExample
{
interface IA
{
void MethodA();
}
class Program : IA
{
static void Main(string[] args)
{
IA InterfaceA = new Program();
InterfaceA.MethodA();
Console.ReadKey();
}

void IA.MethodA()
{
Console.WriteLine("This is a test");
}

}
}

Is This Answer Correct ?    6 Yes 4 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is collection of classes in c#?

711


Why do we use threads in c#?

715


What is byte c#?

614


Is multilevel inheritance possible in c#?

642


How many bytes is an int in c#?

673


In a C# class we have a SortedList member m_addinProjects we want to provide an iterator to allow the consumer of this class access to the items in the collection. Please provide an iterator method for the AnalyzeAddinsDLL class below and an example of how it would be used. namespace AnalyzeAddinsDLL { public class AllAddInProjects { private SortedList m_addinProjects; public AllAddInProjects() { m_addinProjects = new SortedList(); } } }

2048


What is final keyword in c#?

692


How you will create satellite assemblies?

679


Is c# pass by value?

656


what happens if you inherit multiple interfaces and they have conflicting method names?

654


What is the data provider name to connect to access database?

692


Is c# used for frontend or backend?

799


Distinguish between a class and struct?

687


What is the difference between internal and protected in c#?

631


Can we extend sealed class in c#?

664