Click here to Skip to main content
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 10: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 Sergey Alexandrovich Kryukov 686
1 OriginalGriff 345
2 CPallini 200
3 PIEBALDconsult 150
4 Magic Wonder 131
0 OriginalGriff 5,795
1 Sergey Alexandrovich Kryukov 5,028
2 CPallini 4,700
3 George Jonsson 3,142
4 Gihan Liyanage 2,450


Advertise | Privacy | Mobile
Web02 | 2.8.140916.1 | Last Updated 9 Nov 2012
Copyright © CodeProject, 1999-2014
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