Advertisement
Gillito

Untitled

Jul 21st, 2015
226
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.32 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 ConsoleApplication58
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             Person person = new Person("James", "Paul", "Abbot");
  14.             person.WithMiddleName = true;
  15.             Console.WriteLine(person.FullName);
  16.         }
  17.     }
  18.  
  19.     class Person
  20.     {
  21.         public Person(string fName, string mName, string lName)
  22.         {
  23.             FirstName = fName;
  24.             MiddleName = mName;
  25.             LastName = lName;
  26.         }
  27.  
  28.         public string FirstName
  29.         {
  30.             get;
  31.             private set;
  32.         }
  33.         public string MiddleName
  34.         {
  35.             get;
  36.             private set;
  37.         }
  38.         public string LastName
  39.         {
  40.             get;
  41.             private set;
  42.         }
  43.         public bool WithMiddleName
  44.         {
  45.             get;
  46.             set;
  47.         }
  48.         public string FullName
  49.         {
  50.             get
  51.             {
  52.                 if (WithMiddleName == true)
  53.                     return FirstName + " " + MiddleName + " " + LastName;
  54.                 else
  55.                     return
  56.                         FirstName + " " +LastName;
  57.             }
  58.         }
  59.     }
  60. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement