Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Hi , I need your help in C# please. I need to complete the code below for practice but I am not familiar with it
Hi I need your help in C# please. I need to complete the code below for practice but I am not familiar with it yet.
Here is the code below.
using System;
using System.Collections.Generic;
namespace GLA
class Contact
public string Name get; set;
public long Phone get; set;
class Program
public static void DisplayListAllList myList
if myListCount
Console.WriteLineList is empty!";
else
Console.WriteLine
All Contacts from the phonebook:
;
foreach var item in myList
Console.WriteLineName: Phone: item.Name, item.Phone;
public static string ConvertToNameCasestring name
return nameToStringToUpper name.Substring;
Complete the ToDo Methods, additionally, you may also add new methods, if you need.
public static void DisplayAllContactsOfAUserNameList myListyou may change parameters if required
ToDo
All contacts of a single user name
if an user have two contact number, print user name once followed by contact numbers
please see provided inputoutput for the formatting
public static Contact FindContactGivenAPhoneList myList, long phone
ToDo: remove the return null statement and complete the method
Note: this method should return a Contact object
return null;
public static List FindAllContactsOfAGivenNameList myList, string name
ToDo: remove the return null statement and complete the method
Note: this method returns a List of Contacts; even if a single contact record exists for the given name
return null;
ToDo Methods
static void Mainstring args
List contactList new List;
string command;
do
Console.WriteLine
Enter a command: ;
command Console.ReadLine;
command command.ToLower;
while commandContains command command.Replace;
command command.Trim;
var split command.Splitnull;
if splitLength
if split "exit"
break;
else if split "findall"
DisplayListAllcontactList;
else if splitLength continue;
else if split "add"
for int i ; i split.Length ; i
spliti ConvertToNameCasespliti;
contactList.Addnew Contact Name string.Join split, split.Length Phone long.ParsesplitsplitLength ;
else if split "find"
ToDo
Complete this block
separate the correctly formatted name from the 'split' array
choose the method to find all contacts when given a user name
choose method to display all contacts of that user name
NB: A user name can have one or more contact numbers
else if split "update"
ToDo update
ToDo
Complete this block
separate old number from the 'split' array
choose the method to find a contact when given the old phone number
remove the contact containing the old phone number from the contactList
extract the correctly formatted new user name and the from the 'split' array
Add a new contact object into the contactList with and
else
Console.WriteLineUnknown command!
Please enter command in correct format...";
while true;
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started