Advertisement
Qrist

InterfaceIPerson

Jun 16th, 2020
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.76 KB | None | 0 0
  1. using System;
  2.  
  3. namespace PersonInfo
  4. {
  5.     interface IPerson
  6.     {
  7.          string Name { get; set; }
  8.          int Age { get; set; }
  9.  
  10.     }
  11.     public class Citizen : IPerson
  12.     {
  13.         public Citizen(string name,int age)
  14.         {
  15.             Name = name;
  16.             Age = age;
  17.         }
  18.         public string Name { get; set ; }
  19.         public int Age { get ; set; }
  20.     }
  21.     public class StartUp
  22.     {
  23.     }
  24.  
  25.     class Program
  26.     {
  27.         static void Main(string[] args)
  28.         {
  29.             string name = Console.ReadLine();
  30.             int age = int.Parse(Console.ReadLine());
  31.             IPerson person = new Citizen(name, age);
  32.             Console.WriteLine(city.Name);
  33.             Console.WriteLine(city.Age);
  34.  
  35.         }
  36.     }
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement