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 ConsoleReadInvitations
- {
- public class Politician
- {
- public string LastName { get; set; }
- public string FirstName { get; set; }
- public string Gender { get; set; }
- public string Title { get; set; }
- public string Party { get; set; }
- public string Salutation { get; set; }
- public Politician(string line)
- {
- string name = line.Substring(0, 20).Trim();
- int position = name.IndexOf(",");
- this.LastName = name.Substring(0, position);
- this.FirstName = name.Substring(position + 2);
- this.Gender = line.Substring(20, 1);
- this.Title = this.Gender == "M" ? "Mr." : "Ms.";
- this.Party = line.Substring(28);
- this.Salutation = String.Format($"Dear {Title} {FirstName} {LastName} of the {Party} party:");
- }
- }
- }
Add Comment
Please, Sign In to add comment