using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Interface_Example
{
public interface IEditPicture
{
void Paint();
}
public interface IEditImage:IEditPicture
{
//This will hide the method of IEditPicture's
new void Paint();
}
public interface IDrawing : IEditPicture
{
//Bydefault this will hide the IEditPicture's Method
void Paint();
}
public class Studio : IEditImage,IDrawing
{
/*
* For Explicit declaration of Interface don't use any access modifier
* InterfaceName.methodName() will be written instead of writting direct method name
*/
//This is IEditImage Method
void IEditImage.Paint()
{
Console.WriteLine("Paint Method of {IEditImage}");
}
//This is IDrawing Method
void IDrawing.Paint()
{
Console.WriteLine("Paint Method of {IDrawing}");
}
//This is IEditPicture Method
void IEditPicture.Paint()
{
Console.WriteLine("Paint Method of {IEditPicture}");
}
//This is Class Method
public void Paint()
{
Console.WriteLine("Paint Method of Studio Class" );
}
}
class Program
{
static void Main(string[] args)
{
Studio sd = new Studio();
((IEditImage)sd).Paint();
((IDrawing)sd).Paint();
((IEditPicture)sd).Paint();
//This will call method of Studio Class
sd.Paint();
Console.Read();
}
}
}
No comments:
Post a Comment