Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3693936
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T04:26:12+00:00 2026-05-19T04:26:12+00:00

I am trying to make a simple phone directory program in windows console application.

  • 0

I am trying to make a simple phone directory program in windows console application. I have used SortedDictionary in which Key is name and Value is number, List for address and StringDictionary for email-ids. I put all of these in a class named Directory and then called it through an instance in Main. I am facing problem in enumerating the directory. I want to print all four entries of a person in same line. Can anyone tell me how should I proceed. This is how I was trying.I am well sure of that there are many mistakes in my logic..Sorry for inconvenience:-

public class Directry    
{      
    List <string> Email_id= new List <string>();

    SortedDictionary<string, int> Dict = new SortedDictionary<string, int>();
    StringCollection Adress=new StringCollection();
    public Directry(SortedDictionary<string, int> dict, StringCollection adress, List<string> email)
    {
       this.Dict = dict;
       this.Email_id = email;
       this.Adress = adress;
    }      
}

class Another
{
    static void Main(string[] args)
    {
        SortedDictionary<string, int> dict = new SortedDictionary<string, int>();
        List<string> email = new List<string>();
        StringCollection adres = new StringCollection();
        Directry dir = new Directry( dict, adres,email);
        string key, adress, Email;
        int numbr;
        start_again:
        for (int i = 0; i <2; i++)
        {
            Console.WriteLine("enter name to be added in the directory");
            key = Console.ReadLine();
            Console.WriteLine("enter number to be added in the directory");
            numbr = Convert.ToInt32(Console.ReadLine());
            Console.WriteLine("enter address to be added in the directory");
            adress = Console.ReadLine();
            Console.WriteLine("enter your email-id to be added in the directory");
            Email = Console.ReadLine();
            dict.Add(key, numbr);
            email.Add(Email);
            adres.Add(adress);
        }
        Console.WriteLine("do you wish to continue-y/n?");
        char c = Convert.ToChar(Console.ReadLine());
        if (c == 'y')
        {
            Console.WriteLine("you said yes");
            goto start_again;
        }
        else
        {
            Console.WriteLine("no more entries can be added");
            Console.WriteLine("Name         Number          adress            email");
            foreach (object ot in dir)
            {
                Console.WriteLine(ot);
            }               
        }
        Console.ReadLine();
    }
}

Thanks.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-19T04:26:12+00:00Added an answer on May 19, 2026 at 4:26 am

    This code is far from perfect but it should get you on your way.

     public class Directory
    {
        public List<string> EmailAddresses = new List<string>();
        public List<string> Addresses = new List<string>();
    
        public void Add(string email, string address)
        {
            EmailAddresses.Add(email);
            Addresses.Add(address);
        }
    }
    
    class Another
    {
        static void Main(string[] args)
        {
    
            SortedDictionary<string, Directory> _directory = new SortedDictionary<string, Directory>();
            string key, adress, Email;
            int numbr;
        start_again:
            for (int i = 0; i < 2; i++)
            {
                Console.WriteLine("enter name to be added in the directory");
                key = Console.ReadLine();
                Console.WriteLine("enter number to be added in the directory");
                numbr = Convert.ToInt32(Console.ReadLine());
                Console.WriteLine("enter address to be added in the directory");
                adress = Console.ReadLine();
                Console.WriteLine("enter your email-id to be added in the directory");
                Email = Console.ReadLine();
    
                Directory dir = new Directory();
                dir.Add(Email, adress);
    
                _directory.Add(key, dir);
    
            }
            Console.WriteLine("do you wish to continue-y/n?");
            char c = Convert.ToChar(Console.ReadLine());
            if (c == 'y')
            {
                Console.WriteLine("you said yes");
                goto start_again;
            }
            else
            {
                Console.WriteLine("no more entries can be added");
                Console.WriteLine("Name         Number          adress            email");
                foreach (KeyValuePair<string, Directory> d in _directory)
                {
                    Console.WriteLine(string.Format("{0}, {1}, {2}", d.Key, d.Value.Addresses.First(), d.Value.EmailAddresses.First()));
                }
            }
            Console.ReadLine();
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to make put together a simple application to control the phone
I'm trying to make a simple blackjack program. Sadly, I'm having problems right off
I am trying to make a simple program that handles files and directories, but
I'm trying to make a simple app with glade/gtk/vala. So far I have this:
I'm trying to make a simple image browser for TinyMCE which I am using
I'm trying to put together a simple RSS feed reader in windows phone 7
I'm trying to make a simple route which catches this: /static_stuff.php?blablabla&moreblabla=blablabl&evenmorebla=moreblablabl I need to
I'm trying to make a simple C# web server that, at this stage, you
Trying to make a MySQL-based application support MS SQL, I ran into the following
I have a simple question. I am trying to design a simple Android app,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.