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?