Main Program:
namespace abstractandinterface
{
class Program
{
static void Main(string[] args)
{
////////////////////////////////////////////abstract class inheritance
abstractclass inheritabstract;
inheritabstract = new inheritabstractclass();
string rd = Convert.ToString(Console.ReadLine());
Console.WriteLine("\n");
inheritabstract.Custid = rd;
rd = inheritabstract.commondetails();
Console.WriteLine("Abstract Output\n");
Console.WriteLine(rd);
Console.WriteLine("\n");
Console.Read();
///////////////////////////////////////interface implementation
interfaceclass inheritinterface;
implementinheritance implement = new implementinheritance();
inheritinterface = (interfaceclass)implement;
string rd1 = Convert.ToString(Console.ReadLine());
Console.WriteLine("\n");
implement.custname = rd1;
Console.WriteLine("Interface Ouptput\n");
Console.WriteLine(rd1);
Console.WriteLine("\n");
Console.Read();
}
}
}
Abstract Class:
namespace abstractandinterface
{
abstract class abstractclass
{
string custid;
public string Custid
{
get { return custid; }
set { custid = value; }
}
static string custname;
public static string Custname
{
get { return abstractclass.custname; }
set { abstractclass.custname = value; }
}
public string commondetails( )
{
return custid;
}
public abstract string account();
}
}
Interface Class
namespace abstractandinterface
{
interface interfaceclass
{
string account();
}
}
Inherit Abstract Class
namespace abstractandinterface
{
class inheritabstractclass:abstractclass
{
public override string account()
{
return "";
}
}
}
Implement Interface
namespace abstractandinterface
{
class implementinheritance:interfaceclass
{
static string custid;
public static string Custid
{
get { return implementinheritance.custid; }
set { implementinheritance.custid = value; }
}
public string custname;
private string Custname
{
get { return custname; }
set { custname = value; }
}
private string custaddress;
public string Custaddress
{
get { return custaddress; }
set { custaddress = value; }
}
#region interfaceclass Members
public string account()
{
return custid;
}
#endregion
}
}
Tuesday, November 17, 2009
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment