Advertisement
Qrist

InterfaceMultipleImplementation

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