//how to consume interface fom diff project
using System;
using OOPSProj;
namespace SecondProject
{
class Class1
{
static void Main()
{
Rectangle r = new Rectangle(134, 56);
Console.WriteLine(r.GetArea());
Console.WriteLine("Second Project Second Class");
Console.ReadLine();
}
}
}
Showing posts with label c# abstract class and interface and inheritance. Show all posts
Showing posts with label c# abstract class and interface and inheritance. Show all posts
Sunday, 22 August 2010
source code for using abstact class
//source code for using abstact class
using System;
namespace OOPSProj
{
//code for inheritance
public class Rectangle : Figure
{
//code constuctor
public Rectangle(double width, double height)
{
base.width = width;
base.height = height;
}
public override double GetArea()
{
return width * height;
}
static void Main()
{
Rectangle r = new Rectangle(190, 45);
Console.WriteLine(r.GetArea());
Console.ReadLine();
}
}
}
using System;
namespace OOPSProj
{
//code for inheritance
public class Rectangle : Figure
{
//code constuctor
public Rectangle(double width, double height)
{
base.width = width;
base.height = height;
}
public override double GetArea()
{
return width * height;
}
static void Main()
{
Rectangle r = new Rectangle(190, 45);
Console.WriteLine(r.GetArea());
Console.ReadLine();
}
}
}
using c# code to use abstract and inheritance
//using c# code to use abstract and inheritance
sing System;
namespace OOPSProj
{
//code for inheritance
class Circle : Figure
{
public Circle(double radius)
{
base.radius = radius;
}
public override double GetArea()
{
return 3.14 * radius * radius;
}
static void Main()
{
Circle c = new Circle(45);
Console.WriteLine(c.GetArea());
Console.ReadLine();
}
}
}
sing System;
namespace OOPSProj
{
//code for inheritance
class Circle : Figure
{
public Circle(double radius)
{
base.radius = radius;
}
public override double GetArea()
{
return 3.14 * radius * radius;
}
static void Main()
{
Circle c = new Circle(45);
Console.WriteLine(c.GetArea());
Console.ReadLine();
}
}
}
how to declare abstract class
// source code how to declare abstract class
using System;
namespace OOPSProj
{
public abstract class Fig
{
public double width, height, radius;
public abstract double GetArea();
}
}
using System;
namespace OOPSProj
{
public abstract class Fig
{
public double width, height, radius;
public abstract double GetArea();
}
}
how to declare abstract class
// source code how to declare abstract class
using System;
namespace OOPSProj
{
public abstract class Fig
{
public double width, height, radius;
public abstract double GetArea();
}
}
using System;
namespace OOPSProj
{
public abstract class Fig
{
public double width, height, radius;
public abstract double GetArea();
}
}
code for using abstract class and in heritance
//code for using abstract class and in heritance
using System;
namespace OOPSProj
{//source code for inheritance
class AbstractChild : AbstractParent
{
public override void Mul1(int x, int y)
{
Console.WriteLine(x * y);
}
public override void Div1(int x, int y)
{
Console.WriteLine(x / y);
}
public void show9()
{
Console.WriteLine("hello");
}
static void Main()
{
AbsChild obj = new AbsChild();
AbsParent p = obj;
p.Add(100, 50); p.Sub(350, 45);
p.Mul(245, 35); p.Div(180, 30);
Console.ReadLine();
}
}
}
using System;
namespace OOPSProj
{//source code for inheritance
class AbstractChild : AbstractParent
{
public override void Mul1(int x, int y)
{
Console.WriteLine(x * y);
}
public override void Div1(int x, int y)
{
Console.WriteLine(x / y);
}
public void show9()
{
Console.WriteLine("hello");
}
static void Main()
{
AbsChild obj = new AbsChild();
AbsParent p = obj;
p.Add(100, 50); p.Sub(350, 45);
p.Mul(245, 35); p.Div(180, 30);
Console.ReadLine();
}
}
}
source code how to declare abstract class
//source code how to declare abstract class
using System;
namespace OOPSProj
{
abstract class AbstactParent
{
public void Add1(int x, int y)
{
Console.WriteLine(x + y);
}
public void Sub1(int x, int y)
{
Console.WriteLine(x - y);
}
public abstract void Mul1(int x, int y);
public abstract void Div1(int x, int y);
}
}
using System;
namespace OOPSProj
{
abstract class AbstactParent
{
public void Add1(int x, int y)
{
Console.WriteLine(x + y);
}
public void Sub1(int x, int y)
{
Console.WriteLine(x - y);
}
public abstract void Mul1(int x, int y);
public abstract void Div1(int x, int y);
}
}
Subscribe to:
Posts (Atom)