Advertisement
Guest User

Untitled

a guest
Jan 22nd, 2020
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.93 KB | None | 0 0
  1. using System;
  2.  
  3. public partial class A
  4. {
  5.   protected string text;
  6.  
  7.   public A ( string text)
  8.   {
  9.     this.text = text;
  10.   }
  11.  
  12.   public void DoWork()
  13.   {
  14.     Console.WriteLine ("Do Work!");
  15.   }
  16.  
  17.   public void DoSomething()
  18.   {
  19.     Console.WriteLine ("Do Work {0}", text);
  20.   }
  21. }
  22.  
  23. public partial class A
  24. {
  25.   public void DoWork2()
  26.   {
  27.     Console.WriteLine ("Do Work 2!");
  28.   }
  29. }
  30.  
  31. public partial class B : A
  32. {
  33.   //mora da postoji ovakav konstruktor kao klasi A
  34.   public B(string text) : base(text)
  35.   {
  36.   }
  37.  
  38.   public void DoWork3()
  39.   {
  40.     Console.WriteLine ("Do Work {0} ", text);
  41.   }
  42. }
  43.  
  44.  
  45. public partial class B : A
  46. {
  47.   public void DoWork4()
  48.   {
  49.     Console.WriteLine ("Do Work {0} ", text);
  50.   }
  51. }
  52.  
  53.  
  54. class MainClass {
  55.   public static void Main (string[] args) {
  56.      
  57.      B b = new B("KOLE");
  58.      b.DoWork3();
  59.  
  60.      b.DoWork();
  61.      b.DoWork2();
  62.  
  63.      b.DoWork4();
  64.  
  65.      b.DoSomething();
  66.   }
  67. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement