Welcome to Kodecsharp

Kodecsharp website provides beginners to C# programming some examples to use the C# API (Application Programming Interface) to develop applications. Learning from some examples will hopefully decrease the time required to learn C#.

In this website you will find a lot of examples which grouped by the C# API namespace. You can easily find a solution to your problem and the entire examples provided here are free. Enjoy your study, come and visit the site regularly to find more and more examples of C# code.

You can also checkout the examples published on this website from our GitHub website on the following address: https://github.com/wsaryada/kodecsharp

--
I Wayan Saryada
Kodecsharp Webmaster


How do I use do-while statement?

The do-while executes a statement or a block of statement inside the {} until the condition defined in the while statement has a false value. The block will be executed at least one time in the program execution because the conditional check is done a the end of the block.

In the following example the do-while statement prints an asterisk character as long as the variable i has a value less than 10.

using System;

namespace Kodecsharp.Example.Intro
{
    class DoWhileDemo
    {
        public static void Main(string[] args)
        {
            int i = 0; // initialize an int variable

            //
            // iterate the loop while the value of i is still less 
            // than 10.
            //
            do
            {
                Console.WriteLine("*");
                i++; // increment the value of i
            } while (i < 10); 

            Console.ReadLine();
        }
    }
}

And here is the result of our program:

*
*
*
*
*
*
*
*
*
*