Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- namespace ConsoleApplication3
- {
- internal class Program
- {
- public static void Main(string[] args)
- {
- var person = new Employee();
- person.Age = 5;
- person.Name = "hujowe";
- person.Gender = "plec";
- person.ListDetails();
- }
- public class Person
- {
- public int Age; // czy serio musze przy kazdej deklaracji deklarowac public/private?
- public string Name;
- public string Gender;
- }
- public class Employee : Person
- {
- public int RoomNr = Room.Number;
- public void ListDetails()
- {
- Console.WriteLine("This persons name is {0}," +
- "and is {1} y old," +
- "also, its a {2}, " +
- "and mieszka w pokoju nr {3}",
- Name, Age.ToString(), Gender, Room.Number); //Cannot acces non-static field 'Number'
- } // in static context - ?????????
- }
- public class Room
- {
- public int Number = 5;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement