-->

Monday, March 3, 2014

Subtraction assignment operator in c# programming

Subtraction assignment operator in c# programming

This is type of binary operator, which means it works with more than one operand. In c#, this can be understood from given code
int a=10,b=5;
a -=b;
Console.WriteLine(a);
In this preceding code, we get 5 as a result. It means subtract operand b from a. This types of expression is equivalent to a=a-b. Lets take an simple example with output

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            int a = 10;
            int b = 20;
            b -= a;
            Console.WriteLine(b);
         
            Console.ReadKey();

        }
    }
}

Code generate the following output

Subtraction assignment operator in c# programming

Read other related articles

Also read other articles

© Copyright 2013 Computer Programming | All Right Reserved