Program for abstract class using C sharp Dot net

using System;

interface IPlay
{
string play();
}

class hockey : IPlay
{
string IPlay.play()
{
return “yes ….hockey”;
}
}

class cricket : IPlay
{
string IPlay.play()
{
return “cricket…”;
}
}

class chess : IPlay
{
string IPlay.play()
{
return “chess”;
}
}

class ui
{
public void PlayType(IPlay ptr)
{
Console.WriteLine(ptr.play());
}
public static void Main()
{
ui obj = new ui();
obj.PlayType(new cricket());
obj.PlayType(new hockey());
obj.PlayType(new chess());
}
}

OUTPUT:

cricket…

yes ….hockey

chess

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.