RupeshAcharya60

Abstraction with C#

Jun 15th, 2022 (edited)
288
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.51 KB | None | 0 0
  1. abstract class AreaClass
  2.     {
  3.         abstract public void Area();
  4.     }
  5.  
  6.  
  7.     class Square : AreaClass
  8.     {
  9.         int a;
  10.         public Square(int a)
  11.         {
  12.             this.a = a;
  13.         }
  14.         public override void Area()
  15.         {
  16.             Console.WriteLine(a * a);
  17.         }
  18.     }
  19.     internal class Program
  20.     {
  21.         static void Main(string[] args)
  22.         {
  23.             Square s = new Square(4);
  24.             s.Area();
  25.             Console.ReadKey();
  26.         }
  27.        
  28.     }
Add Comment
Please, Sign In to add comment