wingman007

OOPClassesObjects2bProgram

Mar 18th, 2016
112
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.50 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace World2b
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             // 1. fields
  14.             Person stoyan = new Person();
  15.             // stoyan.name = "Stoyan";
  16.             // stoyan.age = 52;
  17.  
  18.             // Console.WriteLine("My name is {0}. I am {1} years old.", stoyan.name, stoyan.age);
  19.  
  20.             // 2. with getters and setters
  21.             // stoyan.SetName("Stoyan");
  22.             // stoyan.SetAge(52);
  23.  
  24.             // Console.WriteLine("My name is {0}. I am {1} years old.", stoyan.GetName(), stoyan.GetAge());
  25.  
  26.             // 3. Properties
  27.             // stoyan.Name = "Stoyan";
  28.             // stoyan.Age = 52;
  29.             // 4. Auto properties
  30.             // Console.WriteLine("My name is {0}. I am {1} years old.", stoyan.Name, stoyan.Age);
  31.             stoyan.IntroduceYourSelf();
  32.  
  33.  
  34.             Person vanya = new Person("Vanya", 18, 123.12, "Stoyan", "Petko");
  35.             // vanya.Name = "Vanya";
  36.             // vanya.Age = 18;
  37.  
  38.             // Console.WriteLine("My name is {0}. I am {1} years old. And my best friend is {2}", vanya.Name, vanya.Age, vanya[0]);
  39.             vanya.IntroduceYourSelf();
  40.  
  41.  
  42.             /* Procedural
  43.             string[] names = new string[120];
  44.             int ages = 18;
  45.  
  46.             string person2Name = "Stoyan";
  47.             int person2Age = 18;
  48.             */
  49.         }
  50.     }
  51. }
Add Comment
Please, Sign In to add comment