I've got a university assignment and just need to know how to remove an entry from the address book and use it as a method

Here's what I have so far, everything's fine apart from the removing, please make it quite simple

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Assignment2
{
    class Program
    {
        // strings for arrays
        public static string name;
        public static string name2;
        public static string address;
        public static string address2;

        public static bool addressbookloop = false;
        public static string selectioninput;
        public static char selection;


        static void addcontact(string[,] addressbook)
        {
            Console.WriteLine();


            Console.WriteLine("You want to add a new entry");
            Console.WriteLine("Press enter to continue");
            Console.ReadLine();

            Console.WriteLine("Please type in the contacts first name");
            name = Console.ReadLine();

            Console.WriteLine("And what is the contacts last name");
            name2 = Console.ReadLine();

            Console.WriteLine("Please type in the contacts house number and street name");
            address = Console.ReadLine();

            Console.WriteLine("Please type in the contacts town / city");
            address2 = Console.ReadLine();

            Console.WriteLine("CONTACT SAVED");

            Console.WriteLine();

            // Sending to Array
            int i = 0; bool Xs = false;
            do
            {
                if (addressbook[i, 0] == "XXXXXXX")
                {
                    addressbook[i, 0] = name;
                    addressbook[i, 1] = name2;
                    addressbook[i, 2] = address;
                    addressbook[i, 3] = address2;

                    Xs = true;
                }
                else
                {
                    i++;
                }

            } while (Xs == false);

        }

        static void removecontact(string[,] addressbook)
        {
            Console.WriteLine("Which contact do you want to delete");
            
                Console.WriteLine("You wish to delete {0} {1}, {2} {3}'s address.", name, name2, address, address2);
                Console.ReadLine();
   
        }


        static void showaddresses(string[,] addressbook)
        {
            Console.WriteLine("*** Address Book ***");
            Console.WriteLine();
            for (int i = 0; i < addressbook.GetLength(0); i++)
            {
                name = addressbook[i, 0];
                name2 = addressbook[i, 1];
                address = addressbook[i, 2];
                address2 = addressbook[i, 3];
                Console.WriteLine("{0} {1}, {2}, {3}", name, name2, address, address2);
            }
            Console.WriteLine();
            Console.WriteLine("Press enter to go back to the homepage");

        }

        static void Main()
        {
            // starting array
            string[,] addressbook = new string[10, 4];

            for (int i = 0; i < addressbook.GetLength(0); i++)
            {
                for (int j = 0; j < addressbook.GetLength(1); j++)
                {
                    addressbook[i, j] = "XXXXXXX";
                }
            }

            do
            {
                Console.WriteLine("*** My Address Book ***");
                Console.WriteLine();
                Console.WriteLine("Which option would you like to choose");
                Console.WriteLine();
                Console.WriteLine("1. Add new entry");
                Console.WriteLine("2. Remove entry");
                Console.WriteLine("3. Show address book");
                Console.WriteLine();
                Console.WriteLine("Please enter your selection below");
                selectioninput = Console.ReadLine();
                selection = Convert.ToChar(selectioninput);

                switch (selection)
                {
                    case '1':
                        // Add Contact
                        addcontact(addressbook);
                        break;
                    case '2':
                        // Remove contact

                        removecontact(addressbook);
                        break;
                    case '3':
                        // Show addresses
                        showaddresses(addressbook);
                        Console.ReadLine();
                        break;
                    default:
                        Console.WriteLine("This is an invalid selection, Please Try Again");
                        Console.WriteLine();
                        break;

                }
            }
            while (addressbookloop == false);
             


        }

    }
}

There are a couple of other UK students working on the same thing.
Please check this post. Maybe you can work together.

Hi,

You can try removing from array's "removeat(array index) " method to remove particular record..

thanx.

You can try removing from array's "removeat(array index) " method to remove particular record.

From what I understand from looking at the other two sets of requirements, they are supposed to mark the records as available for overwrite by filling the first element in the array with six X "XXXXXX".

Do you HAVE to use arrays? They aren't exactly tuned performance-wise for remove operations. A linked list or binary tree would be the ideal datastructures here.

I'm assuming this is for academic purposes only.
Ive seen this a few places on this site and around the web.

Maybe the next lesson will be "Look how much easier this is with classes and collections". :D

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.