C# While Loop with examples

In this C# program, we will see While Loop with examples.

C# While Loop with examples Code:

private static void Main(string[] args)
        {
            Console.Write("Enter a number between 1-10 : ");
            int input = int.Parse(Console.ReadLine());

            if (input <= 10 && input > 1)
            {
                int i = 1;
                while (i <= input)
                {
                    Console.Write(i.ToString() + ",");
                    i++;
                }
            }
            else
            {
                Console.Write("Invalid number entered.");
            }

            Console.ReadLine();
        }

C# While Loop with examples Output:

CSharp-While-Loop-with-examples

 
We are nothing without our users ! You can help us offer even more high quality content. Please share our page !
Best quality Asp .Net Ajax Control Toolkit tutorials.

Give your valuable comments.

Name
Email
Comment
4 + 5 =
 
About Us | Terms of Use | Privacy Policy | Disclaimer | Contact Us Copyright © 2012-2022 CodingFusion
75 Important SQL Server queries you should know