================================================================================== ========================= ================================================================================== ========================= textual - character (') string= letters (") numerical - integer (+,-) floating point - decimal/rational 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 1. explicit assignment ( x="mike" ) 2. using user's input ( x=console.readline();) (two types of input: echoless, echo) consolekeyinfo y; 2scopes: 1. local 2. class ================================================================================== ========================= ================================================================================== ========================= expression - contains operands and operators string a,b,c; - declare multiple variables bool y=declare and initialize int h=1; g=1; t=o; errors: - type mismatch - overflow - re-declaration types of operators: 1. unary - one operand 2. binary - two operands + * / % +
add unary increment ++ pre;post sub unary decrement -- pre;post mult div modulo (remainder) neg positive
int a = x+y+zo concatination: "i"+"love"+"you" string length: a.string substring: a.substring(0,5) case convertion: a.toupper a.tolower trim: a.trim a.trimend
byte 7x=system.convert.tobyte(b);
================================================================================== ========================= ================================================================================== ========================= type-casting - process of converting data from one type to another. 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 mult/div add/sub relational comparison boolean and boolean or assignment
()
+ - ! x++ x-* / % + < > <= >= == != && || =