コード例 #1
0
ファイル: Program.cs プロジェクト: nimanmvr/TelerikAcademy
        static void Main()
        {
            Phone phone = new Phone();

            string line;

            using (StreamReader reader = new StreamReader("../../phones.txt"))
            {
                while ((line = reader.ReadLine()) != null)
                {
                    string[]   content = line.Split(new char[] { '|' }, StringSplitOptions.RemoveEmptyEntries);
                    PhoneEntry entry   = new PhoneEntry(content[0].Trim(), content[1].Trim(), content[2]);
                    phone.Add(entry.Name, entry);
                }
            }

            var searchByName = phone.Find("Mimi Shmatkata");

            foreach (var value in searchByName)
            {
                Console.WriteLine("{0} | {1} | {2}", value.Name, value.City, value.Number);
            }

            var searchByNameAndCity = phone.Find("Mimi Shmatkata", "Varna");

            foreach (var value in searchByNameAndCity)
            {
                Console.WriteLine("{0} | {1} | {2}", value.Name, value.City, value.Number);
            }
        }
コード例 #2
0
ファイル: Program.cs プロジェクト: nzhul/TelerikAcademy
        static void Main()
        {
            Phone phone = new Phone();

            string line;
            using (StreamReader reader = new StreamReader("../../phones.txt"))
            {
                while ((line = reader.ReadLine()) != null)
                {
                    string[] content = line.Split(new char[] { '|' }, StringSplitOptions.RemoveEmptyEntries);
                    PhoneEntry entry = new PhoneEntry(content[0].Trim(), content[1].Trim(), content[2]);
                    phone.Add(entry.Name, entry);
                }
            }

            var searchByName = phone.Find("Mimi Shmatkata");
            foreach (var value in searchByName)
            {
                Console.WriteLine("{0} | {1} | {2}", value.Name, value.City, value.Number);
            }

            var searchByNameAndCity = phone.Find("Mimi Shmatkata", "Varna");
            foreach (var value in searchByNameAndCity)
            {
                Console.WriteLine("{0} | {1} | {2}", value.Name, value.City, value.Number);
            }
        }
コード例 #3
0
 public void Add(string key, PhoneEntry value)
 {
     names.Add(key, value);
 }
コード例 #4
0
ファイル: Phone.cs プロジェクト: nzhul/TelerikAcademy
 public void Add(string key, PhoneEntry value)
 {
     names.Add(key, value);
 }