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

  • SEARCH
  • Home
  • 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 289061
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T05:52:23+00:00 2026-05-12T05:52:23+00:00

I am working on making an address book in C# 2008. I need to

  • 0

I am working on making an address book in C# 2008. I need to be able to save the contacts and then later display them when the user asked for it. I also need to handle an exception when someone enters an unknown color when writing the person’s favorite color.
This is my code so far:

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

namespace Lab02
{
    class Program
    {


        static void Main(string[] args)
        {
            Contact contact = new Contact();

            Console.WriteLine("Please enter the person's name:");
            contact.Name = Console.ReadLine();

            Console.WriteLine("Please enter the person's e-mail address:");
            contact.Email = Console.ReadLine();

            Console.WriteLine("Please enter the person's favorite color:");
            string tempColor = Console.ReadLine();
            contact.Favoritecolor = (System.Drawing.KnownColor)(Enum.Parse(typeof(System.Drawing.KnownColor), tempColor));
            try
            {

            }
            catch 
            {

            }
            finally
            {
                Console.WriteLine("This is an unknown color. Please enter a known color");
            } 
        }
        class Color
        {
            enum clr
            // This is a list of colors for the user to pick from.
            {
                Red,
                Green,
                Blue,
                Yellow,
                Purple,
                Brown,
                Black,
                Crimson,
                White,
                Turqoise,
                Orange,
                Cyan,
                Pink,
                Gold,
                Silver,
                Bronze,
                Gray,
                Indigo,
                Rust
            }
        }
    }
        class Contact
        {
            //This string represents the person's Name.
            public string Name { get; set; }

            //This string represents the person's Email.
            public string Email { get; set; }

            public System.Drawing.KnownColor Favoritecolor 
            {
                get;
                set;
            }
        }
    }

Can anyone help me please?

  • 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-12T05:52:23+00:00Added an answer on May 12, 2026 at 5:52 am

    Why not list all colors that the user can pick, with the Enum Value, then ask them to enter a number, try and convert it to an enum,then store it. If it fails to convert, let them know it’s invalid.

    Here’s a little snippet to help. You’ll need to make your enum public however.

    Console.WriteLine("Here are a list of colors:");
    
    foreach(Color.clr item in Enum.GetValues(typeof(Color.clr)))
    {
        Console.WriteLine(string.Format("{0} - {1}",(int)item,item.ToString()));
    }
    Console.WriteLine("Please choose your color");
    string colorInput = Console.ReadLine();
    int colorValue = 0;
    if(!int.TryParse(colorInput, out colorValue))
    {
            Console.WriteLine(string.Format("{0} is not a valid number",colorInput));
            return;
    }
    
    // This will give an error if they've typed a number that wasn't listed
    // So need to add a bit of checking here
    Color.clr tempColor = (Color.clr)colorValue;
    
    // Your code here
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am working on making a book catalog searchable using Solr. I have written
I am working on making a simple drawing program. So far I am able
I am working on making user pages for a certain type of user who
I'm working on making a script with node.js for setting up my dzen2 in
I'm working on making 3 VM versions of XP with IE6, 7, and 8
I'm working on making an ASCII based game, and everywhere I look people are
I am working on making a new SQLite database. Obviously for a number of
I am working on making a twitter client app. One of the requirement of
I'm working on making some code using metaheuristics for finding good solutions to the
I am working on making a web service using soap. I'm stuck at trying

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.