C # beginners of applets-simple phone book

Source: Internet
Author: User

[Csharp] // phone book class Person. cs using System; using System. collections. generic; using System. linq; using System. text; namespace simple phone book {class Person {string name; // Name string phone; // call public string name {set {name = value ;}get {return name ;}} public string Phone {set {phone = value;} get {return phone ;}}}// Main Program. cs using System; using System. collections; using System. collections. gen Eric; using System. linq; using System. text; using System. threading. tasks; namespace simple phone book {class Program {// <summary> /// simple phone book // </summary> /// <param name = "args"> </param> static void Main (string [] args) {Console. title = "simple phone book"; // Console Title ArrayList telArray = new ArrayList (); // used to store the phone while (true) {Console. clear (); // Clear the Console. writeLine ("******************"); Console. writeLine ("* Welcome to use this System * "); Console. writeLine ("**************************"); Console. writeLine ("*. add, v. view, q, exit * "); // simple prompt interface string select = Console. readLine (). toString (); if (select = "a") // Add the phone {Console. write ("Enter name:"); string name = Console. readLine (); Console. write ("Enter the phone number:"); string phone = Console. readLine (); telArray. add (new Person () {Name = name, Phone = phone});} else if (select = "v") // view call {Console. Clear (); Console. writeLine ("telephone number book"); Console. writeLine ("name phone"); foreach (object person in telArray) {Console. writeLine ("{0} {1}", (Person) person ). name, (Person) person ). phone);} Console. read ();} else if (select = "q") // exit the program {www.2cto.com Console. clear (); Console. writeLine ("Welcome, thank you !! "); Console. ReadKey (); return ;}}}}}

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.