Đề thì trắc nghiệm môn AP C# 1 Aptech fpt
//========Hãy tự tìm và làm lại đáp án này chỉ đê tham khảo=======//
3-abc
4-a AJAX
5-a
6-b Convert
7-d XAML
8-a Store
9-c
10-bc
11-b LINQ
12-d
13-c
14-d
16-b
____________________________________
/ Tất cả các đáp án trên đủ để bạn vượt \
\ qua! Chúc các bạn vận dụng thành công /
--------------------------------------------------
\ ^__^
\ (oo)\___________
(__)\ )\/\
||---------------w |
|| ||
class Program
Test C# 2016
using ContactManager; using System; using System.Collections; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace ContactManager { class Program { static void Main(string[] args) { Hashtable hash = new Hashtable(); int choice; do { Console.WriteLine("\n================"); Console.WriteLine("1.Add new contact"); Console.WriteLine("2.Find a contact by name"); Console.WriteLine("3.Display contact"); Console.WriteLine("4.Exit"); choice = int.Parse(Console.ReadLine()); switch (choice) { case 1: new MethodContact().add(hash); break; case 2: new MethodContact().search(hash); break; case 3: new MethodContact().display(hash); break; case 4: break; } } while (choice != 4); } } }
class MethodContact
Test C# 2016
using System;
using System.Collections;
namespace ContactManager
{
class MethodContact
{
public Hashtable add(Hashtable hash)
{
Contactmanager cm = new Contactmanager();
Console.Write("contact name: ");
cm.ContactName = Console.ReadLine();
Console.Write("Phone number: ");
cm.PhoneNumber = Console.ReadLine();
if (cm.ContactName.Length != 0 && cm.PhoneNumber.Length != 0)
{
hash.Add(cm.ContactName, cm.PhoneNumber);
}
return hash;
}
public void display(Hashtable hash)
{
ICollection key = hash.Keys;
Console.WriteLine("\tContactName\t\tPhone");
foreach (string s in key)
{
Console.WriteLine("\t" + s + "\t\t\t" + hash[s]);
}
}
public Hashtable search(Hashtable hash)
{
Console.Write("Enter name search: ");
string name = Console.ReadLine();
Console.WriteLine("\n\tContatName\t\tPhone");
int flag = 0;
ICollection key = hash.Keys;
foreach (string s in key)
{
if (s.Equals(name))
{
Console.WriteLine("\t" + s + "\t\t\t" + hash[s]);
flag = 1;
}
}
if (flag == 0)
{
Console.WriteLine("Name not found");
}
return hash;
}
}
}
class Contactmanager
Test C# 2016
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ContactManager
{
class Contactmanager
{
public string ContactName { get; set; }
public string PhoneNumber { get; set; }
public Contactmanager()
{
}
public Contactmanager(string contactname, string phone)
{
ContactName = contactname;
PhoneNumber = phone;
}
}
}
0 nhận xét:
Post a Comment