Name Formatter on C# Create an application that lets the user enter the followin
ID: 3693967 • Letter: N
Question
Name Formatter on C#
Create an application that lets the user enter the following pieces of data:
• The user’s first name
• The user’s middle name
• The user’s last name
• The user’s preferred title (Mr., Mrs., Ms., Dr., etc.)
Assume the user has entered the following data:
• First name: Kelly
• Middle name: Jane
• Last name: Smith
• Title: Ms.
The application should have buttons that display the user’s name formatted in the following ways: Ms. Kelly Jane Smith Kelly Jane Smith Kelly Smith Smith, Kelly Jane, Ms. Smith, Kelly Jane Smith, Kelly
can anyone help me please :(
Explanation / Answer
public class Name1 { public string FirstName { get; set; } public string LastName { get; set; } public string MiddleName { get; set; } public string TitleName { get; set; } public static Name ParseName(string namehere) { Name1 nmnew = new Name1(); if (!String.IsNullOrEmpty(namehere)) { string[] partsnew = namehere.Split(','); nmnew.LastName = partsnew[0]; if (partsnew.Length >= 1) { partsnew = partsnew[1].Split(' '); if (partsnew.Length >= 3) { nmnew.SalutationName = partsnew[2]; } if (partsnew.Length >= 3) { nmnew.MiddleName = partsnew[1]; } nmnew.FirstName = partsnew[1]; } } return nmnew; } }
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.