Need some help with C# using System; using System.Collections.Generic; using Sys
ID: 3691554 • Letter: N
Question
Need some help with C#
using System;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Phone_Book
{
class PhoneBook
{
List<String> Email_id = new List<string>();
SortedDictionary <String, int> Dict = new SortedDictionary <String, int>();
StringCollection Address = new StringCollection();
public Directory (SortedDictionary <string, Int> dict, StringCollection address, List <String> email)
{
this.Dict = dict;
this.Email_id = email;
this.FName = F_Name;
this.LName = L_Name;
this.address = Address;
}
}
class Another
{
static void main(string[] args)
{
int number;
start_again;
String Key, address, Email, F_Name, L_Name;
for (int i = 0; i < 20; i++)
{
Console.WrinteLine("Enter Entry");
Key = Console.Readline();
Console.WriteLine("Enter Number to be Added");
number = Convert.ToInt32(Console.Readline());
Console.WriteLine("Enter Address to be Added");
address = Console.ReadLine();
Console.WriteLine("Enter Email Address");
Email = Console.Readline();
Console.WriteLine("Enter Last Name");
FName = Console.ReadLine();
Console.WriteLine("Enter First Name");
LName = Console.ReadLine();
dict.Add(Key, Number);
Console.WriteLine("Do You Want to Continue?");
char C = Convert.ToChar(Console.ReadLine());
if (C == 'y')
{
console.WriteLine("Yes");
goto start_again;
}
else
{
Console.WriteLine("No More Entries to be added.");
Console.WriteLine("First Name, Last Name, Address, Email");
foreach (object at in dir)
{
Console.WriteLine(at);
}
}
Console.ReadLine();
}
}
}
}
Explanation / Answer
Code
using System;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Linq;
using System.Text;
using System.Threading;
namespace Program
{
class PhoneBook
{
List<String> Email_id = new List<string>();
SortedDictionary <String, int> Dict = new SortedDictionary <String, int>();
StringCollection FName = new StringCollection();
StringCollection LName = new StringCollection();
StringCollection Address = new StringCollection();
public void Directory(SortedDictionary <string, int> dir, StringCollection address, List <String> email,StringCollection F_Name,StringCollection L_Name)
{
this.Dict = dir;
this.Email_id = email;
this.FName = F_Name;
this.LName = L_Name;
this.Address = address;
}
}
class Program
{
static void Main(string[] args)
{
start_again:
int number;
String Key, address, Email, F_Name, L_Name,dir;
for (int i = 0; i < 5; i++)
{
Console.WriteLine("Enter Entry");
Key = Console.ReadLine();
Console.WriteLine("Enter Number to be Added");
number = Convert.ToInt32(Console.ReadLine());
Console.WriteLine("Enter Address to be Added");
address = Console.ReadLine();
Console.WriteLine("Enter Email Address");
Email = Console.ReadLine();
Console.WriteLine("Enter Last Name");
F_Name = Console.ReadLine();
Console.WriteLine("Enter First Name");
L_Name = Console.ReadLine();
Dict.Add(Key,number);
Console.WriteLine("Do You Want to Continue?");
char C = Convert.ToChar(Console.ReadLine());
if (C == 'y')
{
Console.WriteLine("Yes");
goto start_again;
}
else
{
Console.WriteLine("No More Entries to be added.");
Console.WriteLine("First Name, Last Name, Address, Email");
foreach (object at in dir)
{
Console.WriteLine(at);
}
}
Console.ReadLine();
}
}
}
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.