Advertisement
Guest User

Untitled

a guest
Mar 26th, 2019
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.25 KB | None | 0 0
  1. using System;
  2.  
  3. namespace ConsoleApplication3
  4. {
  5. internal class Program
  6. {
  7. public static void Main(string[] args)
  8. {
  9. var person = new Employee();
  10. person.Age = 5;
  11. person.Name = "hujowe";
  12. person.Gender = "plec";
  13. person.ListDetails();
  14. }
  15. public class Person
  16. {
  17. public int Age; // czy serio musze przy kazdej deklaracji deklarowac public/private?
  18. public string Name;
  19. public string Gender;
  20. }
  21. public class Employee : Person
  22. {
  23. public int RoomNr = Room.Number;
  24. public void ListDetails()
  25. {
  26. Console.WriteLine("This persons name is {0}," +
  27. "and is {1} y old," +
  28. "also, its a {2}, " +
  29. "and mieszka w pokoju nr {3}",
  30. Name, Age.ToString(), Gender, Room.Number); //Cannot acces non-static field 'Number'
  31. } // in static context - ?????????
  32. }
  33. public class Room
  34. {
  35. public int Number = 5;
  36. }
  37. }
  38. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement