Documente Academic
Documente Profesional
Documente Cultură
=========================
==================================================================================
=========================
c# data types:
=======================================
string | string x;
x = "eisen lewis sy";
x= "mike";
=======================================
int(4bytes) | int x;
x=0;
=======================================
float(4bytes) | float x;
x=3.1415f;
=======================================
char | char x;
x='a';
=======================================
bool | bool graduating;
graduating=false;
graduating=true;
=======================================
short(2bytes) | short x;
x=10000;
=======================================
long(8bytes) | long x;
x=1000000l;
=======================================
double(8bytes) | double x;
x=3.14231;
=======================================
byte(1byte) | byte x;
x=128;
=======================================
decimal(12bytes) | decimal x; |
x=3.25465454684m;
=======================================
*no reserved/keywords
no special characters(not special chars: a-z,a-z,0-9,_)
must not start with a number
maximum characters must not exceed
==================================================================================
=========================
==================================================================================
=========================
==================================================================================
=========================
==================================================================================
=========================
2 ways to assign values to variables
2scopes:
1. local
2. class
==================================================================================
=========================
==================================================================================
=========================
errors:
- type mismatch
- overflow
- re-declaration
types of operators:
1. unary - one operand
2. binary - two operands
int a = x+y+zo
concatination:
"i"+"love"+"you"
==================================================================================
=========================
==================================================================================
=========================
string to number(vice-versa)
number to number
2kinds of type-casting
1.implicit - performed automatically by c#
2.explicit - explicitly invoked by the user
num.tostring();
num3=(long)num;
system.convert.to(x);
int.parse(x);
boolean
and (&&)
or (||)
not (!)
comparison operator
== is equal to
!= not equal to
< less than
> greater than
<= less than or equal to
>= greater than or equal to
operator precedence
grouping ()
unary + - ! x++ x--
mult/div * / %
add/sub + -
relational < > <= >=
comparison == !=
boolean and &&
boolean or ||
assignment =