Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace ConsoleApplication58
- {
- class Program
- {
- static void Main(string[] args)
- {
- Person person = new Person("James", "Paul", "Abbot");
- person.WithMiddleName = true;
- Console.WriteLine(person.FullName);
- }
- }
- class Person
- {
- public Person(string fName, string mName, string lName)
- {
- FirstName = fName;
- MiddleName = mName;
- LastName = lName;
- }
- public string FirstName
- {
- get;
- private set;
- }
- public string MiddleName
- {
- get;
- private set;
- }
- public string LastName
- {
- get;
- private set;
- }
- public bool WithMiddleName
- {
- get;
- set;
- }
- public string FullName
- {
- get
- {
- if (WithMiddleName == true)
- return FirstName + " " + MiddleName + " " + LastName;
- else
- return
- FirstName + " " +LastName;
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement