Do calculation with int variable in CSharp

Description

The following code shows how to do calculation with int variable.

Example


using System;/*w  ww  .j av a 2s .c o m*/
public class MainClass {
    static void Main(string[] args) {
        int a;
        a = -42;
        Console.WriteLine("{0}", a);

        int b = 2;
        int c = 42;
        a = b * -c;
        Console.WriteLine("{0}", a);
    }
}

The code above generates the following result.





















Home »
  C# Tutorial »
    Data Types »




C# Data Types
Bool
Byte
Char
Decimal
Double
Float
Integer
Long
Short
String
C# Array
Array Example
Byte Array
C# Standard Data Type Format
BigInteger
Complex
Currency
DateTime
DateTimeOffset
DateTime Format Parse Convert
TimeSpan
TimeZone
Enum
Null
tuple
var