Namespace consoleapplication1
{
Class Program
{
Static void main (string [] ARGs)
{
/* Apply expressions */
// Operator priority:
// Metaoperator: (x), x. y, f (x), a [X], X ++, X --, new, typeof, sizeof, checked, uncheck
// Unary operator: + ,-,~! , ++ X, -- X, (t) x
// Arithmetic Operators: +,-, *,/, and %
// Bitwise operators: <, >>, &, |, ^ ,~
// Relational operators: <,>, <=,> =, is, and
// Logical operators: &, |, ^
// Conditional operators: &, | ,?
// Assignment operators: =, + =,-=, * =,/=, <=, >>=, & =, ^ =, and | =
// All operators except the value assignment operator are left-bound.
// Arithmetic Operators
Int A = 10;
Int B = 20;
Int c = 3;
Int x = A + B;
Int y = 1 + 4;
Int z = 1 +;
Int P = B-;
Int q = B/y;
Int T = A * C;
Int u = A % C;
Int v = A ++;
Int W = ++ B;
Console. writeline ("A + B =" + x );
Console. writeline ("1 + 4 =" + y );
Console. writeline ("1 + A =" + Z );
Console. writeline ("B-A =" + p );
Console. writeline ("B/5 =" + q );
Console. writeline ("A * c =" + t );
Console. writeline ("A % C =" + U );
Console. writeline ("A ++ =" + V + "A =" + );
Console. writeline ("+ + B =" + W );
// Relational operators
String a1 = "hello ";
String a2 = "hello ";
String a3 = "hey ";
If (a1 = a2)
{
Console. writeline ("Equal ");
Console. writeline (a1 = a2). tostring ());
}
Else
{
Console. writeline ("not equal ");
Console. writeline (a1 = a2). tostring ());
}
If (a1 = A3)
{
Console. writeline ("Equal ");
Console. writeline (a1 = A3). tostring ());
}
Else
{
Console. writeline ("not equal ");
Console. writeline (a1 = A3). tostring ());
}
// Logical operators
Bool mybool = true;
Bool nottrue =! Mybool;
Bool Yu = mybool & nottrue;
Bool oth = true;
If (Yu & OTH)
{
Console. writeline ("true ");
}
Else
{
Console. writeline ("false ");
}
Int res = 1;
If (convert. toboolean (RES ))
{
Console. writeline ("true ");
}
Else
{
Console. writeline ("false ");
}
// Bitwise Operator
Int resu = 4;
Console. writeline (resu <1). tostring ());
Console. writeline (resu & res). tostring ());
Console. writeline ((~ Resu). tostring ());
// Value assignment operator
Int B1, B2, B3, B4;
B1 = b2 = B3 = B4 = 1;
B1 + = 1;
B2 = B2 + 1;
B3 <= 1;
B4 & = 1;
Console. writeline (b1 + "" + B2 + "" + B3 + "" + B4 );
// Conditional Operators
Bool C1 = true;
String C2 = C1? "True": "false ";
Console. writeline (c2.tostring ());
Console. readkey (); // wait for the user to enter
}
}
}