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

Is system a class in c#?

496


How do you specify a custom attribute for the entire assembly (rather than for a class)?

525


What do you know about device context?

529


What are the basic string operations? Explain.

514


Do loops in c#?

503






Is there an equivalent to the instanceof operator in visual j++?

521


What's the difference between class and object?

486


Is clr a compiler?

495


What are satellite assemblies?

561


Why do we override in c#?

496


What is the difference between null and string empty in c#?

465


what is a destructor?

606


What is clr namespace?

494


Is c# lazy thread safe?

492


What is inheritance in csharp?

523