Answers for "c# increae by one"

C#
0

c# increae by one

using System;

class Program
{
    static void Main()
    {
        //
        // Shows how increments work.
        //
        int i = 0;
        Console.WriteLine(i);

        i++; // Add one
        Console.WriteLine(i);

        i += 2; // Add two
        Console.WriteLine(i);

        ++i; // Add one
        Console.WriteLine(i);

        i += i; // Multiply by two
        Console.WriteLine(i);

        //
        // Uses increments and assigns.
        //
        int v = 0;
        v = i++; // Increment after value copy
        Console.WriteLine(v);
        Console.WriteLine(i);

        v = ++i; // Increment before value copy
        Console.WriteLine(v);
        Console.WriteLine(i);
    }
}/*
0       -
1       Added one
3       Added two
4       Added one
8       Added itself
8       Value copy
9       Increment
10      Value copy
10      Increment */
Posted by: Guest on December-28-2020

C# Answers by Framework

Browse Popular Code Answers by Language