Click here to Skip to main content
Sign Up to vote bad
good
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


3 solutions

(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  
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 - 8-Nov-12 18:23pm
You're studying computer science at Anglia Ruskin, aren't you?
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
Your Filters
Interested
Ignored
     
0 Christian Graus 544
1 Ron Beyer 296
2 OriginalGriff 258
3 samadhan_kshirsagar 229
4 Sergey Alexandrovich Kryukov 183
0 Sergey Alexandrovich Kryukov 7,007
1 Prasad_Kulkarni 3,815
2 OriginalGriff 3,557
3 _Amy 3,372
4 CPallini 2,975


Advertise | Privacy | Mobile
Web02 | 2.6.130617.1 | Last Updated 9 Nov 2012
Copyright © CodeProject, 1999-2013
All Rights Reserved. Terms of Use
Layout: fixed | fluid