当前位置: 首页>>代码示例>>C#>>正文


C# Card.addMail方法代码示例

本文整理汇总了C#中Card.addMail方法的典型用法代码示例。如果您正苦于以下问题:C# Card.addMail方法的具体用法?C# Card.addMail怎么用?C# Card.addMail使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Card的用法示例。


在下文中一共展示了Card.addMail方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: workingWithXml

        private static void workingWithXml()
        {
            var contact1 = new Phone("1234", "4321");
            var contact2 = new Mail("dada", "netnet");

            var card1 = new Card(123,345,"cardName");
            card1.addMail("dada", "netnet");
            card1.addPhone("1234", "4321");

            Console.WriteLine(card1.ToXml());
        }
开发者ID:NidentalEgor,项目名称:CSharp,代码行数:11,代码来源:Program.cs

示例2: Main

        static void Main(string[] args)
        {
            string input = null;
            Card newCard = new Card();
            // Чтобы нельзя было ввести весь номер только в одном поле при удалении.
            string phoneOrEmail = "a";
            string phoneZoneOrAlias = "b";

            do
            {
                Console.WriteLine("Enter what do you want to do:");
                Console.WriteLine("1 - add contact");
                Console.WriteLine("2 - print all contacts");
                Console.WriteLine("3 - delete contact");
                Console.WriteLine("4 - exit\n");

                input = Console.ReadLine();
                switch (input)
                {

                    case "1":
                        {

                            Console.WriteLine("Enter '1' to add phone\nEnter '2' to add email");

                            input = Console.ReadLine();
                            if (input == "1")
                            {
                                Console.WriteLine("Enter phone:");
                                phoneOrEmail = Console.ReadLine();
                                Console.WriteLine("Enter phone zone:");
                                phoneZoneOrAlias = Console.ReadLine();
                                Console.WriteLine("\n");
                                newCard.addPhone(phoneOrEmail, phoneZoneOrAlias);
                            }
                            else
                                if (input == "2")
                            {
                                Console.WriteLine("\nEnter email:");
                                phoneOrEmail = Console.ReadLine();
                                Console.WriteLine("Enter alias:");
                                phoneZoneOrAlias = Console.ReadLine();
                                Console.WriteLine("\n");
                                newCard.addMail(phoneOrEmail, phoneZoneOrAlias);
                            }
                            else
                            {
                                Console.WriteLine("\nInvalid input data!\n");
                            }
                        }
                        break;
                    case "2":
                        {
                            newCard.getContacts();
                        }
                        break;
                    case "3":
                        {
                            if (newCard.size > 0)
                            {

                                Console.WriteLine("Enter '1' to delete phone\nEnter '2' to delete email");
                                input = Console.ReadLine();
                                if (input == "1")
                                {
                                    Console.WriteLine("Enter phone:");
                                    phoneOrEmail = Console.ReadLine();
                                    Console.WriteLine("Enter phone zone:");
                                    phoneZoneOrAlias = Console.ReadLine();
                                    Console.WriteLine("\n");
                                    newCard.deleteContact(phoneOrEmail, phoneZoneOrAlias);
                                }
                                else
                                    if (input == "2")
                                {
                                    Console.WriteLine("\nEnter email:");
                                    phoneOrEmail = Console.ReadLine();
                                    Console.WriteLine("Enter alias:");
                                    phoneZoneOrAlias = Console.ReadLine();
                                    Console.WriteLine("\n");
                                    newCard.deleteContact(phoneOrEmail, phoneZoneOrAlias);
                                }
                                else
                                {
                                    Console.WriteLine("\nInvalid input data!\n");
                                }
                            }
                            else
                            {
                                Console.WriteLine("\nNo contacts!\n");
                            }
                        }
                        break;
                    case "4":
                        {
                            Environment.Exit(0);
                        }
                        break;
                    default:
                        {
//.........这里部分代码省略.........
开发者ID:NidentalEgor,项目名称:CSharp,代码行数:101,代码来源:Main.cs

示例3: Main

        static void Main(string[] args)
        {
            string input = null;
            Card newCard = null;
            // Чтобы нельзя было ввести весь номер только в одном поле при удалении.
            var phoneOrEmail = "a";
            var phoneZoneOrAlias = "b";

            try
            {

                do
                {
                    Console.WriteLine("Enter what do you want to do:");
                    Console.WriteLine("1 - add card");
                    Console.WriteLine("2 - add contact to card");
                    Console.WriteLine("3 - print all contacts as string");
                    Console.WriteLine("4 - print content of card as Xml");
                    Console.WriteLine("5 - delete contact");
                    Console.WriteLine("6 - delete card");
                    Console.WriteLine("7 - exit\n");

                    input = Console.ReadLine();

                    switch (input)
                    {
                        case "1":
                        {
                            newCard = new Card();
                            Console.WriteLine("Enter Id:");
                            newCard.ProjectId = Convert.ToInt32(Console.ReadLine());
                            Console.WriteLine("Enter Name:");
                            newCard.Name = Console.ReadLine();
                            Console.WriteLine("Enter SynCode:");
                            newCard.SynCode = Convert.ToInt32(Console.ReadLine());
                            Console.WriteLine("\n");
                        }
                            break;
                        case "2":
                        {
                            if (newCard == null)
                                throw new Exception("Card does not exist!");

                            Console.WriteLine("Enter '1' to add phone\nEnter '2' to add email");

                            input = Console.ReadLine();
                            switch (input)
                            {
                                case "1":
                                    Console.WriteLine("Enter phone:");
                                    phoneOrEmail = Console.ReadLine();
                                    Console.WriteLine("Enter phone zone:");
                                    phoneZoneOrAlias = Console.ReadLine();
                                    Console.WriteLine("\n");
                                    newCard.addPhone(phoneOrEmail, phoneZoneOrAlias);
                                    break;
                                case "2":
                                    Console.WriteLine("\nEnter email:");
                                    phoneOrEmail = Console.ReadLine();
                                    Console.WriteLine("Enter alias:");
                                    phoneZoneOrAlias = Console.ReadLine();
                                    Console.WriteLine("\n");
                                    newCard.addMail(phoneOrEmail, phoneZoneOrAlias);
                                    break;
                                default:
                                    Console.WriteLine("\nInvalid input data!\n");
                                    break;
                            }
                        }
                            break;
                        case "3":
                        {
                            if (newCard == null)
                            {
                                throw new Exception("Card does not exist!");
                            }
                            Console.WriteLine(newCard.GetContacts());
                        }
                            break;

                        case "4":
                        {
                            if (newCard == null)
                            {
                                throw new Exception("Card does not exist!");
                            }
                            Console.WriteLine(newCard.ToXml());
                        }
                            break;
                        case "5":
                        {
                            if (newCard == null)
                                throw new Exception("Card does not exist!");

                            if (newCard.Size > 0)
                            {

                                Console.WriteLine("Enter '1' to delete phone\nEnter '2' to delete email");
                                input = Console.ReadLine();
                                switch (input)
//.........这里部分代码省略.........
开发者ID:NidentalEgor,项目名称:CSharp,代码行数:101,代码来源:Program.cs


注:本文中的Card.addMail方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。