Click here to Skip to main content
11,413,676 members (77,039 online)
Rate this: bad
good
Please Sign up or sign in to vote.
I need to create a console application that stores a users name and phone number in a multidimensional array, at the moment I do not know how to get the program to read the information that the users has entered and store it in an array.

What I have so far

 
using System;
public class Phonebook
{
    public static void Main()
    {
        String inputname, inputPhoneNo, userselection;
 
        String[,] name = new string[20,20];
 

        Console.WriteLine("Please select and option" +
        Environment.NewLine + "1. Add Entry" +
        Environment.NewLine + "2. Delete Entry" +
        Environment.NewLine + "3. Print Book to Screen" +
        Environment.NewLine + "4. Continue 'Y' or 'N'");
        userselection = Console.ReadLine();
 
        switch (userselection)
        {
            case "1":
           string [] = Console.ReadLine();
                break;
Posted 4-Nov-12 11:05am
PaulN18103
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

(If I got you) You need something like this:

public static void Main()
    {
      String inputname, inputphoneno, userselection;
 
      String[,] addrbook = new string[20, 2];
 
      int n = 0;
      do
      {
        Console.WriteLine("Please select and option" +
        Environment.NewLine + "1. Add Entry" +
        Environment.NewLine + "2. Delete Entry" +
        Environment.NewLine + "3. Print Book to Screen" +
        Environment.NewLine + "4. Quit");
        userselection = Console.ReadLine();
 
        switch (userselection)
        {
          case "1":
            Console.WriteLine("Name:");
            addrbook[n,0] = Console.ReadLine();
            Console.WriteLine("Phone No.:");
            addrbook[n,1] = Console.ReadLine();
            break;
          case "2":
            // code for entry removal
            break;
          case "3":
            // code for printing the address book
            break;
          case "4":
            break;
        }
        n++;
      } while (userselection != "4");
    }
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

Could you please explain a bit about that part which prints the code and removing the code?
I am struggling on them.
  Permalink  
Comments
PaulN18 at 8-Nov-12 18:23pm
   
You're studying computer science at Anglia Ruskin, aren't you?
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 3

no worries, I sorted the matter out.
  Permalink  

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 OriginalGriff 379
1 Maciej Los 210
2 Sascha Lefévre 175
3 Kornfeld Eliyahu Peter 170
4 KARTHIK Bangalore 145
0 Sergey Alexandrovich Kryukov 9,035
1 OriginalGriff 7,387
2 Maciej Los 3,640
3 Abhinav S 3,298
4 Peter Leow 3,084


Advertise | Privacy | Mobile
Web04 | 2.8.150427.2 | Last Updated 9 Nov 2012
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100