Calculation using compound assignment - CSharp Language Basics

CSharp examples for Language Basics:Operator

Description

Calculation using compound assignment

Demo Code

using System;/*from   w  w  w.j a  va 2 s  .co m*/
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
class Program
{
   static void Main(string[] args)
   {
      // Input
      Console.Write("Enter a number: ");
      string input = Console.ReadLine();
      int number = Convert.ToInt32(input);
      // Calculation using compound assignment
      number += 10; // same as number = number + 10;
      // Result output
      Console.WriteLine("Number ten more greater is: " + number);
   }
}

Result


Related Tutorials