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


C# NaturalNumbers.ToString方法代码示例

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


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

示例1: Main

        static void Main(string[] args)
        {
            string prompt = "> ";
            Console.WriteLine("What do you want me to do?");
            Console.Write(prompt);
            string response = Console.ReadLine();
            if (response == "natural numbers")
            {
                Console.WriteLine("How many?");
                Console.Write(prompt);
                string response_length = Console.ReadLine();
                int length;
                bool parsed = int.TryParse(response_length, out length);
                if (parsed)
                {
                    NaturalNumbers nats = new NaturalNumbers();
                    Console.WriteLine(nats.ToString(nats.GetSequence(length)));
                }
                else
                {
                    Console.WriteLine("Whoops!");
                }

            }
            else{
                Console.WriteLine("Nope! Do better next time.");
            }
            Console.WriteLine("Press any key to exit...");
            Console.ReadKey();
        }
开发者ID:juan-rod,项目名称:mathmagician,代码行数:30,代码来源:Program.cs

示例2: PrintSequenceOfNumbers

 public void PrintSequenceOfNumbers()
 {
     NaturalNumbers nats = new NaturalNumbers();
     int length = 7;
     string expected = "1 2 3 4 5 6 7";
     string actual = nats.ToString(nats.GetSequence(length));
     Assert.AreEqual(expected, actual);
 }
开发者ID:britcorona,项目名称:mathmagician,代码行数:8,代码来源:NaturalNumbersTests.cs

示例3: Main

        static void Main(string[] args)
        {
            string prompt = "> ";
            Console.WriteLine("What do you want me to do?");
            Console.Write(prompt);
            string response = Console.ReadLine();
            if (response.ToLower().Contains("numbers"))
            {
                Console.WriteLine("How many?");
                Console.Write(prompt);
                int length;
                string response_length = Console.ReadLine();
                bool parsed = int.TryParse(response_length, out length);
                if (parsed && Convert.ToInt32(response_length) < 1000)
                {
                    if (response.ToLower().Equals("natural numbers"))
                    {
                        NaturalNumbers nats = new NaturalNumbers();
                        Console.WriteLine(nats.ToString(nats.GetSequence(length)));
                    }
                    else if (response.ToLower().Equals("even numbers"))
                    {
                        EvenNumbers even = new EvenNumbers();
                        Console.WriteLine(even.ToString(even.GetSequence(length)));
                    }
                    else if (response.ToLower().Equals("odd numbers"))
                    {
                        OddNumbers odd = new OddNumbers();
                        Console.WriteLine(odd.ToString(odd.GetSequence(length)));
                    }
                    else if (response.ToLower().Equals("fibonacci numbers"))
                    {
                        Fibonacci fib = new Fibonacci();
                        Console.WriteLine(fib.ToString(fib.GetSequence(length)));
                    }
                    else if (response.ToLower().Equals("prime numbers"))
                    {
                        PrimeNumbers prime = new PrimeNumbers();
                        Console.WriteLine(prime.ToString(prime.GetSequence(length)));
                    }
                    else
                    {
                        Console.WriteLine("Whoops!");
                    }

                }
                else {
                    Console.WriteLine("Whoops!");
                }
            }
            else {
                Console.WriteLine("Nope! Do better next time.");
            }
            Console.WriteLine("Press any key to exit.");
            Console.ReadKey();
        }
开发者ID:tombler,项目名称:mathmagician,代码行数:56,代码来源:Program.cs

示例4: Main

 static void Main(string[] args)
 {
     string prompt = "> ";
     string splash = @"         ,/   *
       _,'/_   |
       `("")' ,'/
        _ _,-M-./ /
        \_\_\.   /    __  __       _   _                           _      _
      )"" |  (    |  \/  | __ _| |_| |__  _ __ ___   __ _  __ _(_) ___(_) __ _ _ __
       __/   M   \__ | |\/| |/ _` | __| '_ \| '_ ` _ \ / _` |/ _` | |/ __| |/ _` | '_ \
       \    /|\    / | |  | | (_| | |_| | | | | | | | | (_| | (_| | | (__| | (_| | | | |
        `--'|||`--'  |_|  |_|\__,_|\__|_| |_|_| |_| |_|\__,_|\__, |_|\___|_|\__,_|_| |_|
       ==^==                                             |___/";
     Console.WriteLine(splash);
     Console.WriteLine("What do you want me to do?");
     Console.Write(prompt);
     string[] valid_responses = new string[] { "natural numbers", "even numbers", "odd numbers", "fibonacci numbers", "prime numbers"};
     string response = Console.ReadLine().ToLower();
     if (valid_responses.Contains(response))
     {
         Console.WriteLine("How many?");
         Console.Write(prompt);
         string response_length = Console.ReadLine();
         int length;
         bool parsed = int.TryParse(response_length, out length);
         if (parsed)
         {
             if (response == "natural numbers")
             {
                 NaturalNumbers nats = new NaturalNumbers();
                 Console.WriteLine(nats.ToString(nats.GetSequence(length)));
             }
             if (response == "even numbers")
             {
                 EvenNumbers even = new EvenNumbers();
                 Console.WriteLine(even.ToString(even.GetSequence(length)));
             }
             if (response == "odd numbers")
             {
                 OddNumbers odd = new OddNumbers();
                 Console.WriteLine(odd.ToString(odd.GetSequence(length)));
             }
             if (response == "fibonacci numbers")
             {
                 FibonacciNumbers fibonacci = new FibonacciNumbers();
                 Console.WriteLine(fibonacci.ToString(fibonacci.GetSequence(length)));
             }
             if (response == "prime numbers")
             {
                 PrimeNumbers prime = new PrimeNumbers();
                 Console.WriteLine(prime.ToString(prime.GetSequence(length)));
             }
         }
         else
         {
             Console.WriteLine("Whoops!");
         }
     }
     else
     {
         Console.WriteLine("Nope! Do better next time.");
     }
     Console.Write("Press any key to exit...");
     Console.ReadKey();
 }
开发者ID:NewEvolution,项目名称:mathmagician,代码行数:65,代码来源:Program.cs

示例5: Main

 static void Main(string[] args)
 {
     string prompt = "> ";
                                                             // cw tab tab (console.writeline stub)
     Console.WriteLine("What do you want me to do?");        // WriteLine gets new line
     Console.Write(prompt);                                  // Write keeps on same line
     string response = Console.ReadLine();
     if (response == "natural numbers")
     {
         Console.WriteLine("How much you wan?");
         Console.Write(prompt);
         string response_length = Console.ReadLine();
         int length;
         bool parsed = int.TryParse(response_length, out length);
         if (parsed)
         {
             NaturalNumbers nats = new NaturalNumbers();
             Console.WriteLine(nats.ToString(nats.GetSequence(length)));
         }
         else
         {
             Console.WriteLine("Whoops!");
         }
     }
     else if (response == "odd numbers")
     {
         Console.WriteLine("How much you wan?");
         Console.WriteLine(prompt);
         string response_length = Console.ReadLine();
         int length;
         bool parsed = int.TryParse(response_length, out length);
         if (parsed)
         {
             OddNumbers odd = new OddNumbers();
             Console.WriteLine(odd.ToString(odd.GetSequence(length)));
         }
         else
         {
             Console.WriteLine("Whoops!");
         }
     }
     else if (response == "even numbers")
     {
         Console.WriteLine("How much you wan?");
         Console.WriteLine(prompt);
         string response_length = Console.ReadLine();
         int length;
         bool parsed = int.TryParse(response_length, out length);
         if (parsed)
         {
             EvenNumbers even = new EvenNumbers();
             Console.WriteLine(even.ToString(even.GetSequence(length)));
         }
         else
         {
             Console.WriteLine("Whoops!");
         }
     }
     else if (response == "fibonacci sequence")
     {
         Console.WriteLine("How much you wan?");
         Console.WriteLine(prompt);
         string response_length = Console.ReadLine();
         int length;
         bool parsed = int.TryParse(response_length, out length);
         if (parsed)
         {
             FibonacciNumbers fib = new FibonacciNumbers();
             Console.WriteLine(fib.ToString(fib.GetSequence(length)));
         }
         else
         {
             Console.WriteLine("Whoops!");
         }
     }
     else
     {
         Console.WriteLine("Nope! Do better next time.");
     }
     Console.WriteLine("Press any key to exit...");
     Console.ReadKey();
 }
开发者ID:gregkorte,项目名称:Cohort10,代码行数:82,代码来源:Program.cs

示例6: Main

        static void Main(string[] args)
        {
            string prompt = ">";
            Console.WriteLine("What do you want me to do?");
            Console.Write(prompt);
            string response = Console.ReadLine();
            if (response == "natural numbers")
            {
                Console.WriteLine("How Many?");
                Console.Write(prompt);
                string response_length = Console.ReadLine();
                int length;
                bool parsed = int.TryParse(response_length, out length);
                if (parsed)
                {
                    NaturalNumbers nats = new NaturalNumbers();
                    Console.WriteLine(nats.ToString(nats.GetSequence(length)));
                }
                    else
                {
                    Console.WriteLine("Whoops!");
                };
            }
            else if (response == "even numbers")
            {
                Console.WriteLine("How Many?");
                Console.Write(prompt);
                string response_length = Console.ReadLine();
                int length;
                bool parsed = int.TryParse(response_length, out length);
                if (parsed)
                {
                    EvenNumbers even = new EvenNumbers();
                    Console.WriteLine(even.ToString(even.GetSequence(length)));
                }
                else
                {
                    Console.WriteLine("Whoops!");
                };
            }
            else if (response == "odd numbers")
            {
                Console.WriteLine("How Many?");
                Console.Write(prompt);
                string response_length = Console.ReadLine();
                int length;
                bool parsed = int.TryParse(response_length, out length);
                if (parsed)
                {
                    OddNumbers odd = new OddNumbers();
                    Console.WriteLine(odd.ToString(odd.GetSequence(length)));
                }
                else
                {
                    Console.WriteLine("Whoops!");
                };
            }

            else
            {
                Console.WriteLine("Nope! Do better next time!");
            }
            Console.WriteLine("Press Any Key to Exit");
            Console.ReadKey();
        }
开发者ID:Shelleydaviswise,项目名称:mathmagician,代码行数:65,代码来源:Program.cs

示例7: Main

        static void Main(string[] args)
        {
            string prompt = "> ";
            Console.WriteLine("What do you want me to do?");
            Console.Write(prompt);
            string response = Console.ReadLine();
            if (response == "natural numbers")
            {
                Console.WriteLine("How many?");
                Console.Write(prompt);
                string response_length = Console.ReadLine();
                int length;
                bool parsed = int.TryParse(response_length, out length);
                if (parsed)
                {
                    NaturalNumbers nats = new NaturalNumbers();
                    Console.WriteLine(nats.ToString(nats.GetSequence(length)));
                }
                else
                {
                    Console.WriteLine("Whoops!");
                }

            }
            if (response == "even numbers") {
                Console.WriteLine("How many?");
                Console.Write(prompt);
                string response_length = Console.ReadLine();
                int length;
                bool parsed = int.TryParse(response_length, out length);
                if (parsed)
                {
                    EvenNumbers even = new EvenNumbers();
                    Console.WriteLine(even.ToString(even.GetSequence(length)));
                }
                else
                {
                    Console.WriteLine("Whoops!");
                }
            }
            if (response == "odd numbers")
            {
                Console.WriteLine("How many?");
                Console.Write(prompt);
                string response_length = Console.ReadLine();
                int length;
                bool parsed = int.TryParse(response_length, out length);
                if (parsed)
                {
                    OddNumbers odd = new OddNumbers();
                    Console.WriteLine(odd.ToString(odd.GetSequence(length)));
                }
                else
                {
                    Console.WriteLine("Whoops!");
                }
            }
            if (response == "fibonacci numbers")
            {
                Console.WriteLine("How many?");
                Console.Write(prompt);
                string response_length = Console.ReadLine();
                int length;
                bool parsed = int.TryParse(response_length, out length);
                if (parsed)
                {
                    FibonacciNumbers fibonacci = new FibonacciNumbers();
                    Console.WriteLine(fibonacci.ToString(fibonacci.GetSequence(length)));
                }
                else
                {
                    Console.WriteLine("Whoops!");
                }
            }
            if (response == "prime numbers")
            {
                Console.WriteLine("How many?");
                Console.Write(prompt);
                string response_length = Console.ReadLine();
                int length;
                bool parsed = int.TryParse(response_length, out length);
                if (parsed)
                {
                    PrimeNumbers prime = new PrimeNumbers();
                    Console.WriteLine(prime.ToString(prime.GetSequence(length)));
                }
                else
                {
                    Console.WriteLine("Whoops!");
                }
            }
            else
            {
                Console.WriteLine("Nope! Do better next time.");
            }
            Console.WriteLine("Press any key to exit...");
            Console.ReadKey();
        }
开发者ID:taylormiley,项目名称:mathmagician,代码行数:98,代码来源:Program.cs

示例8: Main

 static void Main(string[] args)
 {
     string prompt = "> ";
     Console.WriteLine(@"What do you want me to do?
     Natural Numers
     Even Numbers
     Odd Numbers
     Fibonacci Numbers
     Prime Numbers");
     Console.Write(prompt);
     string input = getValidstring();
     Console.WriteLine("How many?");
     int inputInt = getValidInt();
     //if (response.ToLower() == "natural numbers")
     //{
     //    Console.WriteLine("How many?");
     //    Console.Write(prompt);
     //    string response_length = Console.ReadLine();
     //    int length;
     //    bool parsed = int.TryParse(response_length, out length);
     //    if (parsed)
     //    {
     //        NaturalNumbers nats = new NaturalNumbers();
     //        Console.WriteLine(nats.ToString(nats.GetSequence(length)));
     //    }
     //    else
     //    {
     //        Console.WriteLine("Whoops!");
     //    }
     //}
     //else
     //{
     //    Console.WriteLine("Nope! Do better next time.");
     //}
     switch (input.ToLower())
     {
         case "natural numbers":
             NaturalNumbers nats = new NaturalNumbers();
             Console.WriteLine(nats.ToString(nats.GetSequence(inputInt)));
             break;
         case "even numbers":
             EvenNumbers evens = new EvenNumbers();
             Console.WriteLine(evens.ToString(evens.GetSequence(inputInt)));
             break;
         case "odd numbers":
             OddNumbers odds = new OddNumbers();
             Console.WriteLine(odds.ToString(odds.GetSequence(inputInt)));
             break;
         case "fibonacci numbers":
             FibonacciNumbers fibs = new FibonacciNumbers();
             Console.WriteLine(fibs.ToString(fibs.GetSequence(inputInt)));
             break;
         case "prime numbers":
             PrimeNumbers primes = new PrimeNumbers();
             Console.WriteLine(primes.ToString(primes.GetSequence(inputInt)));
             break;
         default:
             Console.WriteLine("Whoops!");
             break;
     }
     Console.WriteLine("Press any key to finish . . .");
     Console.ReadKey();
 }
开发者ID:danielcossins,项目名称:mathmagician,代码行数:63,代码来源:Program.cs


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