Você está na página 1de 338



   



       
       


       



        
       

     


                             !
 "" #$"







   



 
 
 

 

 
 ! "
#  $ 
% & $







   



( )*   + ,,-.,,/0 &   0
"1 - +1 ,,/0

  + 0%
& 0   + "
210 "1 %"  34 .,
5/ 6, " 4 (

  1" 7  18  ( 7  18    " 74        .0
&  1"   (  1   9 1 7 "  (1 9" 9 ( 7  
+ 0%0

  7   18  1"   : : 14 9" 9 0 &"   ("  1 8 
 (( 7  984   "    +      1    (    9 (
      "    1 "     1   7      980

8   ((   ; 7  180 8    ;( 8 9  8
1 9  184 9      "    7     1 7 7  8 9  9 
   7  7   7  80

 1   "(   184  "     8   4 
( <<9990(  0<<(8













'





   


9
7 #  $ 


    
        
      
        

   
   ! "#  $%   
  
     &%    

=   9  0! (7  8 >9   ( 9   ?
    (   ( (7 0  ;(4  0! "
  (     4  8  8 "( "  ( 
9    1    "0 &    9."   1 (
  .      9     0 = .(1 19 
  "1 7  "    0

   " 9     0! (70 = " 1    >  ?  " 7 0! 4
(       @ 7  " 7"   0! "   (  "((0 = 8
 1 1 7 # 4    AA4 ("    " 9   1@   (   " 7
#    9 "7" 7" "   "    "" 7 0     7 4  " 
    4   7"   1@   (  (0  0,   "((
7 ( (( )8 9   *  9     7  7"4   =   9 
  ( 7  18     7 0  7""  '0,       ""4 1   
 7 1     7"   ( 0

= (   .18 ( "   ( 9   (   "    0! (7   ( 
 "7" 7  7  7""0 =   7  4 1" (7"    B " 718 9 ( "  
 4  (       "     (  7 1"   8 
'    0

  7" 4

( )  

    

6





   


&1" 
  

 1  ! "  55C4  
  91
 9  1   7     ( "    0
8    7    7  ( " + ("1 1
    17   1 4  9 7"   ',4,,,
" (    9   7  4 7 1
(   DE%

 
     @"    "
0 = 7"    1 9 "  7
"  7    1 (      7 (4
9 ;(  9  F"  7    0  
       7      ("1 1

  0   4 9  
   .184 9    "7" ;( 7 0  
 (      "  2         7
>$1 ?4   91.1 "      9  1"  91    91.1
(( 0

  ,,,4   98 7"   
  0 &   7 7  ;( 7 "  
94  "    4  2&4  4 G   = 4     1"   0

4 9   9 
   ( " 9 "  (  98 H /-,0,,, " F"
     I 1 9 J

( <<9990(  0<


  
 I
  0! 94   " "(  7"    4      0! 9  
9  7  9 0!    "  I
  0  0! (7      74
     "( 7 " 9    9  1 8(   ("0 =   7""4 ;(  
7  '0,   $0

 "(  7 7  ( <<9990(  0<<+!.!9

-





   


&1"  



   "  98  9  E )("
   * 7 G" 
 2  4 " G4  
98         21F"" (" 
K"( )2K* 7  L E" %1
)9990108"008*0
 "     M= 7
     ; 9 L "1F"" (" 
   0
 (   )("  *  
+(  7 ("  4 2   7 G4
8 0

         1@   79


 (  (4 (7 "  0!   #  1
 0
    " (@ "  4 N0!4
&0!      (  7 0!4 9 
     8 &+O0!4 91  4 0!  4
7       10

  1   1    7P0


 7P108"0080










 '0,   ;  7    "4 "    &   " 7   ,,30 $    
   I
    (    7  ;  9 7"   '0,0  9  "
  7  ;(    9 7"     ( 1      (    "
  7"    180

/





   


   = "

   
  


   ! "
#$  %&
' ($  )
"*    +  +,  

 % 
  --
./  
  %  0 "
/ ' + 

  %* 1(


  -
)2( 3
 ""
-4
  %5 
6  %6 /((
  -
1 6   
%*  4
72 
4 /  /4 
1
 $ ."
#$
*' %*  ))
"     
.$8/$ )

3





   


   = +

   
 $ 000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000003
 7  00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000003
  % " 0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000003
 0! &"   0! 98 00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000C
  % " "  )%*000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000C
E=% )E7 =  % "* 0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000C
#" =  ( )#= *000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000005
 98  %1 )%*0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000005
  % " (7 )%* 000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000005
  (  ) *0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000,
K1  )K* 000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000,
 0! 98 0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000,
 (  AA 0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000,
 N" "0! =+ 000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
@   "  00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
1;4 (    N9 1 0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
$  Q" 
 $   &((   000000000000000000000000000000000000000000000000000000000000000000000000000
$8  $" N" "0! 0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
$ N" "0! 000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000'
2    
 $ &((  00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000-
!(   00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000-
 "  G9 000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000/
  G9 0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000/
 E )* E 000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000/
       0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000003
 0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000003
=(  (   1 00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000C
&    
 $ &(( 0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000005
+"      
 $ &(( 00000000000000000000000000000000000000000000000000000000000000000000000000000000005
  

%  000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000'
 + (    ((     ) ( *00000000000000000000000000000000000000000000000000000000000'
N100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000'
   N1  1 000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000''
!      7 1   0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000''
O(   000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000'6
& O(0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000'6
7;   7;  0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000'/

C





   



&   O( 00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000'/
  O(00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000'3
O O( 000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000'5
O(   0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000'5
9   &       000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000'5
 7000  000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000'5
 9000   0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000006
%( = 0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000006-
 7 %(000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000006-
 (  (  1"  7 ( 000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000006/
 0009 %( 000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000006C
9 %(000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000006C
&   0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000065
& + 00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000065
&   "    00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000065
7 %( 0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000-,

   ! "
%  000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000-'
 ( 7  00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000-'
O1@00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000-'
 0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000-6
E000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000--
=      000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000-/
&   1 7   00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000-/
& E7  &1 %  00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000-C
(0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000/,
2  ( 00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000/
"  9 "  (( 0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000/'
 E1 7  000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000/-
 E 1" E 000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000/3
 " 00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000/3
 )* E 7 O1@  000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000003,
+" 00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000003,
E    " O  000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000003
O    " 000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000003
N" ( )" L 7 G9* 00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000003'
7  ( 0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000003-
  1" 7    1@ 0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000003-
#$  %&
' ($  )
%  0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000003C
=  000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000003C
=     000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000035

5





   



=(        00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000C,
 "   =  000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000C'
 1 89 .    " 7  1. ;(0000000000000000000000000000000000000000000000000000000000000C-
 & E7 0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000C3
     & E7 00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000CC
  89000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000CC
O1@  .  1 7  00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000C5
( 000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000005,
2   7  7  1 ( 7 7    1@ 7  (000000000000000000000000000000000000000000000005,
2   9          "1. 000000000000000000000000000000000000000000000000000000000000000005
O     . "     890000000000000000000000000000000000000000000000000000000000000000000000000000000005
 9 89 0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000005-
(    1@ . 2(.    +9 .  000000000000000000000000000000000000000000000000000000000000000000000000000000005/
     89 0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000005/
;    2 .1;  000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000053
"*    +  +,  

 % 
  --
%  00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000055
"" )"* 00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000055
+7    " 0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000055
=     " 000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000,,
"  N" (000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000,6
 " 000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000,-
 ! 7  " 00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000,-
2   " ) "* 0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000,/
E 1"  "  000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000,C
K1   0!00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000,
+"   7  O 000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
0K0)*  0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
!    00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
./  
  %  0 "
%  0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000-
&1  000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000-
= 7 00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000C
=(   E  O  = 700000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
;( (  7  000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000006
     7 "      (00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000-
&  7         7000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000003
/ ' + 

  %* 1(


  -
%  00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000005
&  0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000005
E"   &000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000005
=           7 "   000000000000000000000000000000000000000000000000000000000000'

,





   



=        # &00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000'
  (  (  1" "   0000000000000000000000000000000000000000000000000000000000000000000000000'6
 7 %( 0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000'-
 000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000'C
 &%  0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000'C
 8  000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000006
 R""  0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000006'
+  000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000066

1 000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000066
 "  
1 000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000066
&    
1 000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000006-
    7 
1000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000006-
    ("  00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000006-
K    7 8   "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000006/
8  7  ;  7  ("    10000000000000000000000000000000000000000000000000000000000000000000000063
 %  00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000063
 
     00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000065
       100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000-,
  "  0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000-
)2( 3
 ""
%  0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000--
;(  0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000--
  7 ;( 000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000--
;(      0!000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000-3

   ;(  "   0000007  18 00000000000000000000000000000000000000000000000000000000000000000000000000000-C
2 7  000 1800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000-C
;( I E   8  ( 000000000000000000000000000000000000000000000000000000000000000000000000000000000000-5
 7  18 00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000/
  E"( ;(  "  "(  18 000000000000000000000000000000000000000000000000000000000000000000000000000/'
& (  (   1  "(  1800000000000000000000000000000000000000000000000000000000000000000000000000000//
O (  (  1" ;(
     0000000000000000000000000000000000000000000000000000000000000000000000000000000/3
+7   " 9 " ;( 00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000/C
;(
   0! 9800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000/C
9   ;(  9 89000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000/5
-4
  %5 
%  00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000003
+ 0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000003
 (   " 7      (  000000000000000000000000000000000000000000000000000000000000000000000003
  7 4   1 "  7    000000000000000000000000000000000000000000000000000000000000000000003'
'0  "  7  1   000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000003'
   "  "   00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000003'
 7"   00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000003/







   



+   0! 98 00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000003/
     00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000003/
E" + 00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000003C
=(    E" + 0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000003C
     7  " I    00000000000000000000000000000000000000000000000000000000000000000C,
       
   0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000C
  
    0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000C
& 8  ;( 00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000C'
E"   0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000C-
    9     "1.  0  & 0000000000000000000000000000000000000000000000000000000000000C/
6  %6 /((
  -
%  00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000005,
$ 9 &((    0!0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000005,
$  0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000005,
"   :
 $ : &(( 0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000005
2      0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000005
&    
  00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000005'
N" "0! L  =+ )=  + (     *000000000000000000000000000000000000000000000000000000000005/
=    
 ( 000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000005/
   0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000053
=  (4 " 1"   +1" 00000000000000000000000000000000000000000000000000000000000000000000000000000000000053
 + 00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000053
" ;( 00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000005C
E "   N" " 0! =+000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000055
2  N" "0!  1"  :
 $ : &(( 000000000000000000000000000000000000000000000000000000000000,,
   9 @ 00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000,,
  " (( 7  7000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000,
&       0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000,
&    
  0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000,'
;"   (( 0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000,'
    1   + 00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000,6
2  E  00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000,6
2  "     (( I ((  00000000000000000000000000000000000000000000000000000000,-
+    7   (    00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000,/
$   7   
   000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000,3
 =(    7    $ 9 &((  00000000000000000000000000000000000000000000000000000000000000000000000,
1 6   
%*  4
72 
%  0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
   0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
% ;  000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
&      1; 000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
&      1; 00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000







   



    7   1; 000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000'
% ;    0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000'
1 ;   0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000006
 N900000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000006
 ! 00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000-
& <     "  000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000/
 N9    0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000C
= %   000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000005
&  & = %  77    000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000005
% N9  0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000,
9 = %   % N9  00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000,
&      9   "    0000000000000000000000000000000000000000000000000000000000000000000000000000000000000,
&  =  "  "  000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
   7 % N9   0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
E E " 00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
  000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000'
+  800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000'
$ 9   + ;00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000006
O(  + ; 0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000006
2   O(  + ; 00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000-
   + ; 0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000/
     + ;00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000003
4 /  /4 
%  0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000',
= "  &+O0!0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000',
+77  (   7 &+O0! 0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000'
&  9 7 1 R% F"00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000'
R% %  00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000'
R% =!   00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000'
R% 2+&   0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000'
R% +%    0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000''
7     8 9 &+O0! 0000000000000000000000000000000000000000000000000000000000000000000000000000000000''
&  + "  &+O0!000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000'6
+7        00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000'6
+7      00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000'-
+7           0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000'-
+7    + &( 00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000'/
    7   + 000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000'/
& +  &(( 000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000'3
%  1 000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000'C
        000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000'5
!   "   00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000006

'





   



2(   1 0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000006
"   &(( 000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000006'
%   1   (     7I   000000000000000000000000000000000000000000000000000000000000000000000000066
=     0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000066
&      00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000006/
  )*  7 " (( 00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000006/
  ) 2( *  0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000063
  
  7    " 000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000006C
  
  7    " 0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000-,
=   00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000-
+   0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000-
2   " 00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000-6
(  "000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000-6
2+&   "0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000-6
=!  " 00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000--
+%   " 0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000--
%  "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000--
2   " 9 &+O0!   0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000-/
 7 =  )*  0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000-3
2  + K    N9 0!  000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000-5
& +  &(( 7 + K  0000000000000000000000000000000000000000000000000000000000000000000000000000000000000-5
  +  . 2  "(  1 0000000000000000000000000000000000000000000000000000000000000000000000000000000000/,
    "   %   00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000/
2(   "  =! 4 2+&    +%   00000000000000000000000000000000000000000000000000000000/6
1
 $ ."
%  0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000/-
$  E" 00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000/-
E"    00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000/3
 "   00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000/5
 1 7  0  0  0000000000000000000000000000000000000000000000000000000000000000000000000000000000/5
=   1 7  0  0  000000000000000000000000000000000000000000000000000000000000000000000000000000003,
 +  ;( .  O(  000000000000000000000000000000000000000000000000000000000000000000000000000000000000003,
 +  ;( .  0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000036
 +  ;( .  ;"  0000000000000000000000000000000000000000000000000000000000000000000000003C
2  # )*  9 7 "    0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000035
    000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000C
  %8  E  00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000C
  " +8 0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000C-
#$
*' %*  ))
%  0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000CC
$8  9   000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000CC
O1    &((      = 7 B  0     0000000000000000000000000000CC

6





   



+  &(( B     = 7 0000000000000000000000000000000000000000000000000000000000000000000000000000000CC
O1    ( 7 " $ 9   7 B    0K)* 0000000000000000000000005,
E ("   "  0=O0   0=O0= 7  00000000000000000000000000000000000000000000000000005
0=O0  0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000005
   7 "  )*  0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000005'
(    E    7 "  ()*   E )*  0000000000000000000000000000000000000000000000000000000000000000000056
8   ;  7  7 "  ;)*  00000000000000000000000000000000000000000000000000000000000000000000000000000056
K  &1" 7  7 "  K&1")* 00000000000000000000000000000000000000000000000000000000000000000000000000000056
0=O0= 7  000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000005-
& F"8   ( ;( 000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000005-
E ("  + )7* "  0=O0+   0=O0+= 7  0000000005/
0=O0+ 00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000053
 4     8  7  ;  7 0000000000000000000000000000000000000000000000000000000000000000000053
K      )7   "1.* 7   000000000000000000000000000000000000000000000000000000000000000000000005C
0=O0+= 7  0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000055
+  (( 7  += 7  0000000000000000000000000000000000000000000000000000000000000000000000000000000000',,
 00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000',
&   9 7  77  ( 7  00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000',
 0  B  1 7     0! 798 0000000000000000000000000000000000000000000000000000',
+77  ( 7 7  B     $   700000000000000000000000000000000000000000000000000000000000000000000000','
2  0=O0     9   7 00000000000000000000000000000000000000000000000000000000000000000000000000','
&   (    (    7  70000000000000000000000000000000000000000000000000000000000000000000000000000000000000000','
O(       7  7000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000',6
2       $     9 (   7 0000000000000000000000000000000000000000000000000',/
2     $     9 ; 7000000000000000000000000000000000000000000000000000000000000000',C
   +. 000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000',5
=(      + B & ( ;( 00000000000000000000000000000000000000000000000000000000000',5
   00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000'
       7   B  S! T 1"0000000000000000000000000000000000000000000000'
K  7 9 +  .  =+ 8  7 0000000000000000000000000000000000000000000000'-
&  "     $  9  0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000'C
&   (( 00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000'5
="   &  " <$ 0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000',
=(  (     " 7 00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000'
"     
    000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000'
  7   0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000'
K   00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000''
    ( 000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000'-
    ( (0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000'3
  "   000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000'5
 ( 0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000'5

-





   



!"1 (0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000''
&  "         000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000''6
&  " 9   "  00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000''-
  "   0, 00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000''3
.$8/$ )
%   E000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000''C
K 
( 000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000''C
80  AA000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000''C
K %"8J 0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000''C

/





   


  

$6'
 18       (   0 =  7 1   9 9 1 "   0!
984  % " "     O1@ O   0

=       9 9    ( 9 O1@ O   " "    4
((4 1 4  74 ""4  "    ;( 0

=     7      9 9     9  F"  (   9 (( 
"   9  %14 7"   ( "   4 +4      $ 9
  9  "1 7  4  9  + & 9 &+O0!4    0


0 $ 
O" ;(   1 9 9    =+ )N" "0!*0 $    " 1 0
E7  "  77  N" "0! ,,- ;(  7 74      1 
( << 070< "<;(<0 &    ( " =+4 (+ (4   1 7
( <<9990(0<O( "<+<0 =   (1  "   ;  )"  !(*  9
  0

Q" 9   9       0! 98 +G4 9  1 1  7 7
( << 070< 798<9 <90(0     " 0! ((   4
 (  7 "4      (  " 9   ( ( " 90

 4 7  .$ 9 "4  E  @ "((  ( "  (4 0! "    
1 (  0    7 4  ( <<9990 .(@0<0

  ;(   18 9 9    9  0! 98  0   N" "
,,'4 1" " 98 7  9   0     1  9 E 0

$ 
 )( "  .(*   "1   " 7    0!    0 =   9 9  "
7 7  189 (1 " 9  9 1"  7 94 ;    (  7"0 =  
O1@ O     "      4     # 4 AA   N0 = 74 
1   (9   77  7 AA4  (    OO  7 #      "
(7 7 N" 0

3





   



%8 # 4     9 "(      " 7 (  ) 7<  *4 1" 
(  1    " 4 (     8 0
9 4    #&N&4
     " F" "7" (  7 AA 8 (   4  " 4 (.(
 4 (  ) "  <" .7 *4 7"  (  )  7 7 *   (   
( "((   ;  0 %8 N4   "((   ( 7 (( ) ;    7*0
=   4   "( 9  9   ;  7" "  7 4 1"4  4
 4 4 4   9 &+O0!   

$ / $      9


=  0! &"    0! 98   77  (      ( 9 9 9
"   1   .

$ 8 : 8;


  (   ( 7  0! 98   ;    7"   7  0! 
% " "  )%*4   0! "  7 0 =   798    1   O  
   ;" 7   0! (( 0 O" (  I  "  9  O 1" 
"  %0


  /((
  



8 : 8;



6 *


1*:1  0    ; 
$ 9 ( " 0!  "    0! (   " )"  4 N0!  AA0!* "
"          ;"1 1  4 1"      8 9  E=%
9   ( 1   % " " 0 E=%  (     9  (  
0 2( ( ;" 4  E=% )  *     1  ;"1  )  
*0   "  (  (1   E=%    7  0!  "0
% " #" = 
'  ( 1*  ( 2 

         5 

C





   



<  (
 :< ;
$ " =% (    1 ;"4  %  8  #= (4 9 (  =%  
  ;"1  )0;  0*     7  (7     O0 #=     9 
77  7   (   (  =%       9 U 004 9  7" 
 4  =% 7  7"  I 1        *   0 4  ( 7     "
1  (" "         0 =7  =%        4   ;
 I 4  % "   ) (* ( 9" .( 0 4 7  ( "  7
  )"      7  7"    *4   9 I     @". . (7 
( 0

& #=   9 7  (7 (   O  " 4   (   ; 77 
"    1" (( 0 &4    #= ( 8 9  ; "   7 ;"1 4
   (   1  .    7"   )8 (  1 7  7"  9 
   (4     7"   *0 &" E7      0!   (  9
 " 8 AA  77    ( 7 ;" 4 #=   8 "    7  AA  
  9  (  "    ;  ( 7  )8 91. *0

$  9
   ': ;
 0! 98 (   " 98 ) *  %1 )%* 7  4 "" 80 %
   "  7   (    $ 9 &=    7"   8   E (" 4
 + ""4 =O4 4 4 "4 !98  4 $ 9  4 $1
 4 + &4 0 =  (     1   (( 9   ( 
     (   "0  1 ( 7  1   79 ; 77  OO 
) ( * 8      "  (   (10 Q"  "    %  "
( @"  " 9" "    0 Q"    ((      ((   0 

$ *(0 : *;


4 9 "   I0! (  % "I       0! (   "  8 "
7 %   %0 " 9 8   "  I0! ( I  "H   9    % "
(7 )%*0 E7      7 (7     " "   F"7
  0! (  % "0 & =%      "4     7   "  (   
=% 7"  U 4        "1 7 %  F"7   0! (   "0 
   9     " )("   OO*  9 "   "   0! "10 % 1
  "  "    9   0    4  " I 1   1
7"   4  ( 4  "(        8 0  (  (     
 7 " 8( "  9  % 1" 4 "   "   1 "1     0!
 "0

5





   



$ '(*' : *;
0!  7    (  ) *0 %8 %4       7  0   7   1
 (  =% "  0  0! (   " " (   (     
(0  8  (1 7    "  "  9   1 ( <   (
   7  0  ;(4   7   (4 4     ( 7 ' 1 )6 1* 9 
(( 1  "    N0! "   
 (0

,  

 :, ;
%      K1  )K*4 9 "    9.(    8 7 " .7 4
    (0 =7  7         7  1   1<7 4 
.    "     O0  (  7    K1  7  ( 7
8(  8 7    0 &8   AA ( 9 1  7  J

$   9
 0! 98   1  7  7 %4 %4 +   DE%    " $ 94 $1
((    $1  0 &  7  0! 98  (  19 7 1 "   0

  /((
  
)$ 4 $1 &(( 4 $1  *

4 :/4 ;>1  '

  9
   ': ;
)=O4 4 84 "4 7 4 2=*

8 : 8;


)+1"4 ( 8 4 #= 4 ;( 4 K*

6 *

(   ==


=  7 (7    77    " 7     "4 AA  " 0 " 
(7    (    " 9        (     H !J AA  
"1   (;4 1   9.   "  (0 = 1"  ( 9  
( 1    "((0 &  (1 9 AA        "   4 9   
,





   



 "  "4     7    ( U 004        "   "
14 (   7 0       (  (97"   " 9  1 
9 8(      ;(  7  (        "  0 O  7  1
      (  8   8 (   ."14   14 14 (1  
  1"0    9  "0     AA  ( 8 9 9 77"     
1 AA (   1" 0 =  1    7    9  (   0
   7 4  4   189.(1 "0   AA   "" 7 4 
"" (   "4     1  " 1@   (   "  4   7 
( 9      "" 9 7    (14 9  "  8  8  1@  
((H & @  ""(4  7"  7 AA 4 :AA   ".(  "    OO
 ":0  (    7 "    " "(( 7    " " 4 98 
14    94  1@    7 7  189.(1 "0

$? 
*  4
E7 N" "0!   =  + (      )=+*4 9   " 7 N"
" /0 =    (  ( 7  0! &((  )N0!4 N0!4 NAA0!4 #(0!4
#0!4 &0!4   *0   "  ((   9 (     7   N"
"0! (  % " "   =+4 1"4 (@   " ;(4  94 ((
14  1;4    "   10  8 7" 7 N" "0!  "  =+ ( 
" "7"  (   " 

 G9    ;  
 =   )" (*4 9 ( 1 " (    ;  " (   )0*
9 1@4  " 4 (   9 " "  >!9? 890
 @   "    9 " ;(  (    ((     7
"( 70

( 1"  "  7 9 (    ( "((0
 ( 1  9 "   77  (( 7 "( 9 9   91  0
   1"  9 "  1" " ( "  ("  18 (  7 1  
" . 1 0

 (  8   ; 7 "   " (     7 0
 + 
(   "1 7 ( "   E7 + (  !98 )E+!* 10 
 (    1"  (( 0
  ;" 9  9"  1"0
 +(  " 0! ((    =     80

& ! *


  
& @   1  7 ;"1   1 7  8  ((  "0 & (@I
 7  "" (   7 9  ;  I0(@I 9 II (  .(0 4 N0!







   



(@    I0 1(@I 70     77  8  7 (@ "    &(( 4
$ 9 &(( 4 &0! $1 &(( 4  %1   0

& "        ( 7 77    (@  8  (( 0
 ;(4  "    7  &0! $1 &(( (@    $ 9  (@0 
 7 7  "    I0 I 7    1   "  N" "0!I " ;(0
"     N /I @ K"(   NAA /I 98(0


2+& (  
 ? 
!9      1; 7   N" "0!I  "   0  1; )"" (  
 7   *     "1 7    7 9 94 91    ((  8  ; 1;4
8 1;4  94  1;4  "4 7 ( 4 0

  ( 1 )"" (          =+* 9 "    (( 
    7 9"     0
   N9 1 9     " (@      9     7 
 0     NAA /I  90

6  @  3

6
  
/((
  
=  79  ;4 9 9 1" " 7  (( 94    9"4 N" "0!0 $ 9 
9  94 (4   ;"   (( 0 %   (4 9 9 ;(  77   (
  (0 

6 96 $ ? 


*  
O( !(4     ; 4   9  79   

using System;

namespace MyHelloWorldApplication
{
class HelloWorld
{
static void Main(string[] args)
{
Console.WriteLine("Hello World");
}
}
}







   



   9   7  9  ;  :0:0 ;( IE&(( 0I  (  74  
  ((   9

csc MyFirstApplication.cs


 9 ( " (     0; 7 )E&(( 0;*       9
(      "0

 " " (4 (

MyFirstApplication


 9 ( 
 $   "  "    0 (4  I H %I    (" 9
N" "0!

6 $? 
*  
 E7 N" "0!     . !9 . @U  9 9  ( 7 0  N"
 @ 7 @ (      &(( 7 (0 $ E
$&(( 
  ; 1; 19   8 OG0

'





   



 9 9 "    7"  7 "  9 ((



   "    )    9 <<<*4     7  7  

$   9

Console.WriteLine("Hello World"); in place of //TODO: Add code....


 8  (" 8 8

using System;
namespace MyHelloWorldApplication
{
class HelloWorld
{
[STAThread]
static void Main(string[] args)
{
Console.WriteLine("Hello World");
}
}
}

6





   



!9  (   ;" " (( 4  +1" .  $" +1"   ( A-0  9
(  9   $ 9 9
 $ 9  0 O  " (   84  9 9 9 4
    (0

A  $3

6
/((
  B
 7   7 " ( )"  U* ((  "    (0 =   "    
7"   7 " (" 0 $ 9 "   1 0 %I 7  9     
) ( E
$&(( *  0

 (   


& !(  (    7    0 $ 1"  "   )8 
 9 1  *         ( )004 +& *0 &  
 9 9  9     1 "   (4   ("( 7 "  (  
(     70   (( 9 "     "1 7 4       98
 %1 )%*0 =   " (1  "     +&   7 9 
   7 =  & 0    4     ( 7  (  (0 
 7" F"7  7   9 1 +& 0    =  & 0  4  
     1" 7  (0

4       7 " ( 9      79   )9 V W 18*  ( 7
E
$&(( (0

namespace MyHelloWorldApplication
{
...
}


  (   !O ( ((       # 0  9  (  1 
77  70    ( 7 ((     (8  #    (    AA0 
(    4   4 ;( 4       (  I=  
(I0

-





   



    (  1 7  8 

namespace Parent
{
namespace Child
{
...
}
}

$ C' 
 7   7 " ( 9

using System;


 "  89 1  9 "  "     79  II (0    4 9 
9     7     ( 8 9  1        "
E  0 O  (   1   "  9 "       7 
(          < (0
  9    9

using System.Collections;


      7    ( 9   "1<   ( 7 
(0

$
 C' 
& 7 "  (       0  E )*      7  0   
1  7  )7*   7"   )*   1 (7         
"  " (10 $ 9    ( 7         0    
7  "    89 79 1   7 0

$1:;1 $
=  ;   9 7   E )*  7 " (

static void Main(string[] args)


      " 7  E   0  E      (  7 " (4 004
"  (   ;" 7  7   7 E      9    7 E
0  E          9 1  1   % " "  )%*

/





   



9" 8    1@ 7 "
$  )9   7  7   4 7  
((*0           "   0     ) *  7 
4 9 
 
    7 (   1 (   9 ;"   ( 7
   0 $ 9   0

O     (           "( E )*    (0 "4 "   
;(  7 9 E      (    " .0 AA   #  4 8  
E  9 ( IEI    " (  0

&   $  



O" ;   ( 
 $     

Console.WriteLine("Hello World");

 9  $% )*4    7     7     (0  
8    )   "1 F"*   (   (       9 90

4 8  O1@ O   "4 "   )0* (    1 1 )7*  
 7  0 &4 1 )*  "   7              "1
F" 8 ):*0 %4      )8 4 AA   # *   9   )U*4   
   0

 
    (I ;  ;(  4    1  (      "  
7  ;"1 0  "  ; 7       #    AA0  ; 79  "1
 8 )<<    *     0      9    7   

// This is my main method of program
static void Main()
{
...
}


  "((    180 =  4  9 18    1  (0   7  18
  1 .8 )<X*     9 8. 8 )X<*

static void Main()
{
/* These lines of text
will be ignored by the compiler */
...

3





   



}


  "   8  7    I"   I0   "     
"  7 "    (0          9 (  8 )<<<*

/// These are documentation comments


$ 9 "       " 

(  (     


 Q"  ;"1 (    0
    (   (     E )* 9  " (
         "     N  77 
 $( ) 4 14 (*    1  ( 19  0
 4  79  
    7  E )*  "     

static void
Main ( )
{
...
}


 Q" +O!I     " ( 9  7   7 "      E )* 
   1 "( E )*   " (
  1"  7 (4      7  1 (       " 18 V W
 & (      7  9  ( ((   8 )" 8 # *
  "  89  "   7 ( 9   7  7  7  ) (*
 "  1"  "  "  (0
   ( 7   ;  U  4 18   "  0     1 
(    "        1   "  1 7 ( 7 
 (0
    "    (  ( 0 Q"  9 ( 9 "   
  1   (
 =      E E 7 ( 8 I  ST I  (0 =  (7  
9 E    

static void Main()
{
...
}

C





   



/    53

6
/((
 
2( "  94 9        9 ((    9 9 9   ;"0
% 9 8       9    "  " 7 0  ( 9 8  " 
   9  "  < 4 8 I
 I 9  "  II "  0 %   
7

static void Main(string[] args)
{
Console.Write("Please enter your name: ");
string name = Console.ReadLine();
Console.WriteLine
("Hello {0}, Good Luck in C#", name);
}



 
  
      
 
      

4      53

6
/((
 
=  7  4 9   "   4 $)*4 7    0      $% )*
4 "   ( " (4 1"        7 (         0

=     4 9   1 7  (       I I0  4 9 8    7  (" 7
 " "  % )*  7         "   I I 10 
1  (   7    ( "   ;" 7 (0 N1 
 77  ( 7  (     .(4 004   1     9   1
     )* 7 0  % )*  7     )   $% )**
    7  ("       $ 90 = "    ("    4 9 9   "  
1 I I0

  
   !"   

=    4 9 (      1 "    4   9    ; "   $% )*
 7    0
 9 "  "1" ( V,W   9        
1 I I " 1 9 9  $% )*   0

Console.WriteLine
("Hello {0}, Good Luck in C#", name);


$  ( 7   "1" (4 V W4  (  9  ) A* 1 79    0
     9 "1 F" 8    (  ( 1  0
 4  "
5





   



 9  ( 7  V,W4  (  9 ),A*4 004   1 )I I* 79    0  
" .4  % 9   

Console.WriteLine
("Hello Faraz, Good Luck in C#");


7  " 7 I I    " .0 &  4    1 9 

Console.WriteLine
("Hello " + name + ", Good Luck in C#");


    "1" (0
 9    )*      7  0 )  7
((    I ( 7)* 7"  9       # I $    +, *
$ 9 (   "  (  "(" 9 1

Please enter your name: Faraz
Hello Faraz, Good Luck in C#

',





   


  
 

 &

 9 9    " 7"   7 0 $ 9 ;(   (  4 "  14
(4 79     8 700 4 (  ""   9  " 0

7 4 '(  $ ((  *: '(*' ;


  9 8  7  (  0

 N" ( )(  (4 "    " *
 7  ( )1@4 *

N" (  (   1 (   ; ( 9 7  (  (   1
(     7  ) *0 =(  (  7     "  1   "  4
9 ;(  (  (    1 "   (  (  (0

& 9 9   7 "4 (  (  0! (   "  ((  (   
(  ) *   % ) % " (7 *0
 4  (  (    
(   0! (0  (  (   

 ( 0! (   1 +(

  
'( 
1   E     7 ,.--

1     1 7 .C  3

 = /    7 .'43/C  '43/3

" 2= /  2  4   7 ,  /-4-'-

  )7"* = ' 6   7 .46346C'4/6C  46346C'4/63

"  2= ' 6 2  4   7 ,  645645/345-

  = /6 C   7 .54'4'34,'/4C-6433-4C,C 


54'4'34,'/4C-6433-4C,3

'





   



"  2= /6 C 2  4   7 ,  C466/43664,3'43,54--4/-


 & '( 
7   6   7 Y0- Z ,.6-  Y'06 Z ,'C 9 3 
( 0 F"  "77; I7I  II
"1 +"1 C   7 Y-0, Z ,.'6  Y03 Z ,',C 9 -./
)7"* 

 $ '( 
1       "  7

          2       


F" 8 "  II
 +    7 0, Z ,.C  305 Z ,C 9 C.5 
( 0 F"  "77; II  IEI

=(  (  (    " "  894   7  1    89   )G9
  9 7  1   "     1 "   7*0 =  9        
(  (  4  
   89  0   (  1" (  (     "
(   "    84 9 " 7  (  7  (   "   (0 & 8 
  ""      7  7 " )=O* 7 0 =    7  "(( 1 
(          ( 0 & (   7   1   (  "
0 7  (   "    1 7  (   )"   ;" 7
(*0  1   7  .7    ( "   ;" 7 (  
"   (  O(  0

? 
 
+"   ;" 7  (4   (   0 & 1       
     (" ( 7 0 4  1   9    (    "0
= 4 1   

<data type> <variable>;


004

int i;


 1    9     7 6 1        ( "4 9 9 1 7 
   7 ( 1   7 II0 Q"     1  "   )  7*    
<  "( 1 7   (      4 004

'





   



bool isReady = true;
float percentage = 87.88, average = 43.9;
char digit = '7';


=  )8    "*4 " "  1 17 "  0 &4     ( 7
:+7  &  :   9  : 1 ) 1 7    * " 1   17
1  ":0  79  ( 9 I (

static void Main()
{
int age;
// age = 18;
Console.WriteLine(age); // error
}


"4 7 " " .      4  ( 9 (0     7" "  
10     ( 7  "4 004 " 7 ("  (    1    ( 
) (1*  (0 Q"  I    "    ( 8 9 "    <AA0

  ? 
  *' 

    1 9 "4   7 4   1   1  (0    1 
 "     894 8

const double PI = 3.142;


   1 " 1      0 =    ;   9

const int MARKS;


=       " (  9      10

 5  0 5 


  $ 
E7 " "   ! )7   9* 7 1    ! )7  
"((* 7 0  9 7  7 9    7 1 1    "  9
 ( 0  ;(4 1  79    " 1

salary totalSalary
myMathsMarks isPaid


 (  7  79   ! 

''





   



GetTotal() Start()
WriteLine() LastIndexOf()


&"       79     4       "  79 
   0 E7    "((
"   4 8 "  E8 7   10 &4 " 
 "  [   7    "0

(    
/  $ (   
    (  9  0

(  +(
A &
. "1
X E"(
< + 
\    "
AA =   1 
.. +  1 

 ( 19 "  (0

using System;

namespace CSharpSchool
{
class ArithmeticOperators
{
// The program shows the use of arithmetic operators
// + - * / % ++ --
static void Main()
{
// result of addition, subtraction,
// multiplication and modulus operator
int sum=0, difference=0, product=0, modulo=0;
float quotient=0; // result of division
int num1 = 10, num2 = 2; // operand variables

sum = num1 + num2;


difference = num1 - num2;
product = num1 * num2;
'6





   



quotient = num1 / num2;

// remainder of 3/2
modulo = 3 % num2;

Console.WriteLine("num1 = {0}, num2 = {1}", num1, num2);


Console.WriteLine();

Console.WriteLine ("Sum of {0} and {1} is {2}", num1, num2, sum);


Console.WriteLine("Difference of {0} and {1} is {2}", num1, num2, difference);
Console.WriteLine("Product of {0} and {1} is {2}", num1, num2, product);
Console.WriteLine("Quotient of {0} and {1} is {2}", num1, num2, quotient);
Console.WriteLine();
Console.WriteLine("Remainder when 3 is divided by {0} is {1}", num2, modulo);

num1++; // increment num1 by 1


num2--; // decrement num2 by 1

Console.WriteLine("num1 = {0}, num2 = {1}", num1, num2);


}
}
}


&"  ( 1   F" (4 = 9" 8  "   ( 0 = 
 0$% )* 4 9   " 7.(7 V W     ( 7 1  
 0

Console.WriteLine("Sum of {0} and {1} is {2}", num1, num2, sum);

4 V,W4 VW   VW 9 1 ( 1  " 7  "4 "   " 10 = VW4  (7 
)A* 1 7 "1 F" 9 (  9 (     0
 4 V,W 9 1 ( 1 
7  4 VW 9 1 ( 1    1     000

&  (      "AA       

num1 = num1 + 1;


O

num1 += 1;


)$ 9   ( 7     *

'-





   



& 02& 02  


  AA   .B (  1 "  (7;  (7; (0 = (7; 7

num1 = 3;
num2 = ++num1; // num1 = 4, num2 = 4


 ( 9 7    " 1     9    "0 $  (7; 7

num2 = num1++; // num1 = 4, num2 = 3


 ( 9 7  "  "       " 1 0

/  (   
&   (  "   "  10     (   

(  +(
] (   
A] &    
.] "1    
X] E"(    
<] +    
\] E"   

 F" )]* (  "    "   1@0 %8 9   

bool isPaid = false;


   " I7I    1 7  (0  7         7  F"   
    ( " 1 (14 9  ( 9 ( 1"   ; 0
    " 7 (   4 004        "   1 7 ( "1  
1 7 (  4 9   ((    0

double doubleValue = 4.67;

// intValue will be equal to 4


int intValue = (int) doubleValue;


O7 "4 9     9    7   7 ( U    1 4 9     6 7
   60/30 4     "    "
'/





   





int intValue = 32800;
short shortValue = (short) intValue;
// shortValue would be equal to -32736


N1 7 (     8 "    7 .'3/C  '3/34    1     'C,,
 N"0
  N" 8   / 1 )     7 / 1* 7    'C,,4 9
   " .'3'/ )  1 /4 9 (   " '3/C    4 9 (  .'3/C*0 =7 " 
   (1 ( 8

bool isPaid = false;
int intValue = (int) isPaid;


= 9 I  (    ( 9     ; 0

8
 
(   
  (  " 7 ( ("(      0    ( 
 

(  +(
]] F" 8
J] 2 .F" 8
^ K 
_ % 
^] K   F" 
_] %   F" 

  ( 9 "     U  "  70  ;( 7 9   9
1

int num1 = 5, num2 = 6;




num1 == num2 // false
num1 != num2 // true
num1 > num2 // false
num1 < num2 // true
num1 <= num2 // true
num1 >= num2 // false


'3





   



O  (1  (  1 (0 =     (  1 9   4  7 "  

int i = 1;
bool b = true;


"   (    1 7 F" )]]1*0      9 "    ; 0


7  (   
 (  " 7    19 " 0     19 (   

(  +(
L 9 &!+
` 9 O
a 9 DO
J 9 !O
LL >%?  > "? &!+
`` >%?  > "? O

 ( L4 `   a   "  "" (  (0  !O (  "   
  19 ;( 8

bool b = false;
bool bb = !b;
// bb would be true


% O( LL   ``  "  1  (  8

int i=6, j=12;
bool firstVar = i>3 && j<10;
// firstVar would be false
bool secondVar = i>3 || j<10;
// secondVar would be true


=  7 (  9 "  "   7 1         "  "0
=    (  9 "  " 7   7         "  "0 Q"
 4 7 "4 " 1 LL   ``      8

bool firstVar = (i>3 && j<10) || (i<7 && j>10) // firstVar would be true


=  1    9 " (   "( "    ;(         1"0

'C





   



Q"  " L   ` (  ( 7 LL   `` 1" 7 1      ;( 4 LL   ``  
77  1"  " : "  " :0  ;(4 7   ;( )^' LL @_,*4 ^'
 "  74    ;( @_, 9 I 1 8   7 9 1 "  )9 "  &!+4 7  
7  ((  (   74  9 ( 9 "  7*0
 4   " 1  7"
9 "     ;(  9 LL   `` (0  L   ` (  I   "
 "    ;"   (  17 "    "0

 $ (   
    ( (   0 &  ( 7     19

(  +(
__ %7 7 19 (
^^  7 19 (
0 E1  7 1@
ST = ; ( "      
)*  (
H   (

(   & 


& (    F"0     ( 7 :( ( :  0  ;(

int i = 2 + 3 * 6;
// i would be 20 not 30


' 9 1 "( 1 / 7   " 9 1   0   1"  "( ( X 
(      ( A0   ( 1 7 ( ( 4  " E+!   0!
798 "  0


  
/  
*   
$0
   
  8   9 1   (   "     "  7   7 
1  " 0  (         7 7  7000  0  "" 7
   

if(Boolean expression)
Statement or block of statements
else
Statement or block of statements


'5





   



  " 1   ( 0 & ( ;( 

if(i==5)
Console.WriteLine("Thank God, I finally became 5.");


=  1  ;(4     9 1 (    7  ;( ]]-  "  "0 =7 "
9" 8  8   9       "  "4  "  "  "

if(i==5)
Console.WriteLine ("Thank God, I finally became 5.");
else
Console.WriteLine("Missed...When will I become 5?");


O   7  9 1 (  7   F"  -0 =     )9    -*4     9
1 ( 0 =7 " 9   "  18 7   )     * "  7  4   
" 18  VW 18  

if(i==5)
{
j = i*2;
Console.WriteLine("Thank God, I finally became 5.");
}
else
{
j = i/2;
Console.WriteLine("Missed...When will I become 5?");
}


= 9" 9    " V W 18       79  7      7 "    
    0 =   1   (     1"  9  " 7 "  
( 7 7     0

Q"     7 7  7 7"    

if(i==5) // line 1
{
Console.WriteLine("Thank God, I finally became 5.");
}
else if(i==6) // line 5
{
Console.WriteLine("Ok, 6 is close to 5.");
}

6,





   



else // line 9
{
Console.WriteLine("Missed...When will I become 5 or be close to 5?");
}

  7)]]/*  ;"   7  7   ]]-  74       5 9 1 ;"   7 
    ]]/ )  -* ;"   7 ) 4 1  7        7*0  (  
     5    7    -0

  7000     4 "  "  "   7000   )  *4 8

if(i>5) // line 1
{
if(i==6) // line 3
{
Console.WriteLine("Ok, 6 is close to 5.");
}
else // line 7
{
Console.WriteLine("Oops! I'm older than 5 but not 6!");
}
Console.WriteLine("Thank God, I finally became older than 5.");
}
else // line 13
{
Console.WriteLine("Missed...When will I become 5 or close to 5?");
}


     3     7    ' 9     ' 1   7    0  4  
)<AA ( (*  7   ;(    ;(       "0 =I 
  9

int flag = 0;
if(flag = 1)
{
// do something...
}


= 4 "   "

int flag = 0;
if(flag == 1) // note ==

6





   



{
// do something...
}


4

bool flag = false;
if(flag = true) // Boolean expression
{
// do something...
}


 8      7"   " 7   (; 1  7 7000 


1 7 "  VW 18 9   7   0
 =            10 =7 "  "  N" "0!   
  "((  4   9     7 "0 O94 "    8  7 
"70

=     " 79  1  9 " 0

$  $    


=7 "   (7   7 (7 84 9000  (    @" 7 0    ""
7  9000   

switch(integral or string expression)
{
case constant-expression:
statements
breaking or jump statement
// some other case blocks
...
default:
statements
breaking or jump statement
}


= 8    " 9000  "    7000 7  0 %I 8   9  ;(

using System;

6





   



// To execute the program write "SwitchCaseExample 2" or
// any other number at command line,
// if the name of .exe file is "SwitchCaseExample.exe"
namespace CSharpSchool
{
class SwitchCaseExample
{
// Demonstrates the use of switch...case statement along with
// the use of command line argument
static void Main(string [] userInput)
{
int input = int.Parse(userInput[0]);
// convert the string input to integer.
// Will throw a run-time exception if there is no input at run-time or if
// the input is not castable to integer.
switch(input) // what is input?
{
case 1: // if it is 1
Console.WriteLine("You typed 1 (one) as the first command line argument");
break; // get out of switch block
case 2: // if it is 2
Console.WriteLine("You typed 2 (two) as the first command line argument");
break; // get out of switch block
case 3: // if it is 3
Console.WriteLine("You typed 3 (three) as the first command line argument");
break; // get out of switch block
default: // if it is not any of the above
Console.WriteLine("You typed a number other than 1, 2 and 3");
break; // get out of switch block
}
}
}
}


 ( " 1 "(( 9        " 0 4 (  ( ) 
      N" "0!*0 "(( 9   ; 9  :9;(0;:4 9 9"
"        8 

C:>SwitchCaseExample 2
You typed 2 (two) as command line argument

O

6'





   




C:>SwitchCaseExample 34
You typed a number other than 1, 2 and 3

=7 "           "       .  " 4  ( 9  
;(

C:>SwitchCaseExample
Unhandled Exception: System.IndexOutOfRangeException:
Index was outside the bounds of the array.
at CSharpSchool.SwicthCaseExample.Main(String[] userInput) in
c:\visual studio projects\SwitchCaseExample\
SwitchCaseExample.cs :line 9

%I      98 0 4 9    7     "  )"= ("S,T*     
1  ("0    4 9 "   )*  7     (0   8   
  "   F"        ;( 7   I0 !; 9 8  " 7  (" 1
"   9  

switch(input)
{
...
}


%4   1 7  " 7  ("4 9 8 (7   "  (    0 O  " 
(7    4 9 8  9  18   17   7    )  7"* 180

case 3: // if it is 3
Console.WriteLine("You typed 3 (three) as first command line argument");
break; // get out of switch block


=7   (7 8 7 ) ("    7 4   '*4    "  7" ;"0

default:
// if it is not any of the above
Console.WriteLine ("You typed a number other than 1, 2 and 3");
break; // get out of switch block


   (  (   1 9 "   9000    

 Q"  "    ) " *      9  
  ;( 79   " 1   0 =    "  1 7 

66





   




case i: // incorrect, syntax error


 &   " 7          U
 Q"  " "(   "       7"  

case "Pakistan":
continent = "Asia";
Console.WriteLine("Pakistan is an Asian Country");
break;
default:
continent = "Un-recognized";
Console.WriteLine
("Un-recognized country discovered");
break;


    7     7"    8 9 18 ) *  0 $  I " VW
18  8  18  9000  9 ""   
    9 7."0 4 "  I     7" 9" 18   ) "  
#   <AA*0  ( 9    ( 1"  " 7 7."   9000
 0
  18    7  ;"   " 7  "  180
   "  7" 9 1 ;" 7     7    8 70
 =     ( 7"     7 9000  0 Q"    (  7"
18 17  7    19 U 7" 9 98    7  ( 0

9 4 8  7"   18          0 O7 "4 "  I
      7" 18     90000

(  
%(  " 7  ("(4 004    8 "(  )"" "        *

$0 (
   ( 7 (     7 (0  1 "" 7  7 (  ;     # 
  <AA   

for(assignment; condition; increment/decrement)
statements or block of statements
enclosed in {} brackets


%   7 (  9 9    7   ,    

6-





   




for(int i=1; i<=10; i++)
{
Console.WriteLine("In the loop, the value of i is {0}.", i);
}


&  4    1     9  " 7 0      7 (  ;" 9
   )_],*   "0  " 7      )AA* 1     ( 0

*(  (    $0 


(
&     7)*4   4       <   ( 0 Q"  "  
1  7         "       0  9" 8 9     I= 7  
 7  (I ) (  9     "   "   18  "   "     1 7 
(*0 "4 "     "((  (((   

for(; ;)
for( ; i<10; i++)
for(int i=3; ; i--)
for( ; i>5; )


=7 "  I "  VW 184     79  7)* 9 1      0
 ;( 19          1 

for(int i=1; i<=10; i++)
Console.WriteLine("In the loop, value of i is {0}.", i);


= 9     " 9 " VW 18   ((    0

=7 "   1  7)*I   4  7 )(* 9       (    9  7 
( 1   )" 8  (   7 AA*0
  7 " 9

for(int i=1; i<=10; i++)
{
Console.WriteLine("In the loop, value of i is {0}.", i);
}
i++; // line 1


 ( 9 (      :   "   7:0

Q"  " 18     "  7 (     (      ;" (0 18
   (    7  ;"   (  @" "  7 (

6/





   




for(int i=1; i<=10; i++)
{
if(i>5)
{
break;
}
Console.WriteLine("In the loop, value of i is {0}.", i);
}


 ( 9      " 7     -0 =7     (  7 184 18
" 1   "     4 9    79  18 9 1 " 1   
( 9    9   ) # 4 I   ; *0

for(int i=3; i<10; i++)
{
break; // warning, Console.WriteLine (i); is unreachable code
Console.WriteLine(i);
}


  "       ( 7  "       ;  0

for(int i=1; i<=10; i++)
{
if(i==5)
{
continue;
}
Console.WriteLine("In the loop, value of i is {0}.", i);
}


 0$%  9 1 ;" 7   ;( 9  " 7  1 -0  ( "(" 7
 1   

In the loop, value of i is 1.
In the loop, value of i is 2.
In the loop, value of i is 3.
In the loop, value of i is 4.
In the loop, value of i is 6.
In the loop, value of i is 7.
In the loop, value of i is 8.
In the loop, value of i is 9.

63





   



In the loop, value of i is 10.

$$
(
   "" 7  0009 ( 

do
Statement or block of statements
while(boolean expression);


   "   9 ;"  7         80  ( 9   " 9
     "0
 ( 7 (        ,     "   0009 ( 

int i=1;
do
{
Console.WriteLine("In the loop, value of i is {0}.", i);
i++;
} while(i<=10);


 (  (   

      0009)* ( 9 ;"    0
     U 7  9  0

$
(
 9 (     0009 (4 ;(   8    17     7 
);" 7     1 7  (*0    7 7  9 ( 

while(Boolean expression)
statements or block of statements


O" (  (       ,     "  9 9 1

int i=1;
while(i<=10)
{
Console.WriteLine("In the loop, value of i is {0}.", i);
i++;
}

6C





   



/ '   
/ '4
  
& &    7 " 7    (0  4     7  (0   
   1@      7  0& 0 &   

<data type> [] <identifier> = new <data type>[<size of array>];


% 7    7 (     ,  0

int [] integers = new int[10];


  7    7;   " 1 7  17 "  0
9 4 "  " 1  7   
7  

int size = 10;
int [] integers = new int[size];


Q"  (         ( (

int [] integers;
integers = new int[10];


=   (1  7   "   "  9  1    "  " 18   ( 
  " " 9  

int [] integers = {1, 2, 3, 4, 5};


 9    7  -4 9 "  " 9 1 4 4 '4 6   -0

/  $5


    '
   "   &4 9 "   ;  ( S   ;T0 $   1 (       
9 ("  ; " 9 9  0 =I (      ; "    7 ,0  7 
    -  4  7   9" 1   ; ,4      ;      )77*   ; 60
 79      9    '   7  

int [] intArray = {5, 10, 15, 20};
int j = intArray[2];


%I 8  (  "    0
65





   




// demonstrates the use of arrays in C#
static void Main()
{
// declaring and initializing an array of type integer
int [] integers = {3, 7, 2, 14, 65};
// iterating through the array and printing each element
for(int i=0; i<5; i++)
{
Console.WriteLine(integers[i]);
}
}

 9 "  7 (   "       0$% )*   (     "
  7  0 ! 9   ;  ( ST  "0

 1  (  F" (   77 4 1" 9   .   7     7 (0 & 9
   4     7  (     "1. 7  0& 0    
7 "7" ((      1 ((       7    9 7 0 (  
" 8  1  7        O1@ O   "0 ( 
 ;   4 9     (  " .1""  7 9  "    
       ;0 $ 9 " ((        0 0&   
"7" .  ((  %    1 "  7    4  4 7   (0
2   %  ((4  7 (   1  (  1 9 

for(int i=0; i<integers.Length; i++)
{
Console.WriteLine(integers[i]);
}


  7 (   "  7;1    1 ((    7      7   .(0
!9 9  "    "" ( 7 E )*0 E  ""  

static void Main(string [] args)


     "   9 ( 9 ;"  " (   1  " ( " 
 7 (    7 1     0

0 $(
    ( 7 (    (   "7"   "     0   
7 (0  1 "" 7  7 ( 

-,





   




foreach(<type of elements in collection> <identifier> in <array or collection>)
<statements or block of statements>


%I 9 8 " ( " (   "   9  7 (

// demonstrates the use of arrays in C#
static void Main()
{
// declaring and initializing an array of type integer
int [] integers = {3, 7, 2, 14, 65};
// iterating through the array and printing each element
foreach(int i in integers)
{
Console.WriteLine(i);
}
}


(    14  I H =   

foreach(int i in integers)


$ (7  ( 7      )   " *0 $   1 )*  1 "  
   " " 7   I I    0

=(  (    

  1 "      "   7     )   1  ;(*  
 0 Q"  I         " 0     7 9   9 " 
 "               7 0 =7 " 9  (7 
98          "  4 " " "  7 (0
 7  1 "   "    0    4 9    4 " 
 7  (   = "1  70 )#"  "  (    .    9
(   1      7*
         7  )(  = "1  7   "  
"  "  ((*0  79   ;(      (     
  0

static void Main()
{
string name = "Faraz Rasheed";
foreach(char ch in name)

-





   



{
Console.WriteLine(ch);
}
}


 9 (    7     (  0

-





   



   ! 

 &

 9 9  O1@ O    )OO*  0 $ 9  9    4 1@4  
 10  9 9     "4  74 ((4       
0

( 0
 
&   (  1  "  7   9  (0 &       1  7
 ("  )7  1 1*4 (    1 (7   )*   
  )((*0  ;(4          ( 7 0! 98  %1
)%*0        7  )*   (  77  (  )*   1
((    8 %9)*4 )*4 "1 )*4 0 =    (( 8 %  )" 
7     7   *0
&      "   89     1     ( 

class MyClass
{
// fields, operations and properties go here
}


9 E    7   9  (  9  7   0

 ! 
&    1 4     1 0 & 1@          1"  
 (7 1  0 & 1@      "   89 I 9I    7  1 
 7   :7 :0

MyClass myObjectReference = new MyClass();


=    1 4 9   1@ 7 ( E 9  7  1   7 O1@7 0

 77  19    (  (   1@  7  ( )( 1 7 *
9 (  (  " ( )( 1 8   (*0 &4 1@     ( 9
(  (    80

-'





   



*  
 




  

*   !  *   !  *   ! 




  

 



   
   
  


 
         0   1 (  (4 1@ 7   4
 " 4 "  0 =  ;( 194 9 7     "       " I
4 4 8  4 8   4 8   4  84 1  8    ( 0

class Student
{
// fields contained in Student class
string name;
int age;
int marksInMaths;
int marksInEnglish;
int marksInScience;
int totalMarks = 300; // initialization
int obtainedMarks;
double percentage;
}


Q"      7 9    "  9   E8   ;( 1 0 =7 "  I
   1 7  4  9 1   9  7" "0

-6





   



+7" " 7 77   (  9 19

4 '( +7" N"
  ,
  ,
7 ,0,
"1 ,0,
1 
 Ib,I ) " *
  :: )(  *
O1@ "

1 $  
E   (  (7   0 &   8   (" " "  (
   "  " 7  ("  (0   " 7   8  7

<return type> <name of method>(<data type> <identifier>, <data type> <identifier>,...)
{
// body of the method
}


 ;(4

int FindSum(int num1, int num2)
{
int sum = num1 + num2;
return sum;
}

4 9 7      " 9 8 9 ( 7   ( ) "   "*   " 
 " 7 (   "   89 " 0 =7     "   4  " ( 9" 1 0 &
   (  8  ( ) ( *

void ShowCurrentTime()
{
Console.WriteLine("The current time is: " + DateTime.Now);
}


 1   8  (   "   0 =   (   "  +       
"   +      (0

--





   



    $
 
=        )8   1@* "   9 890

Student theStudent = new Student();


Q"     7      1@    77  (0  79  9   
F"     1   

Student theStudent;
theStudent = new Student();


!       "  (  ( ;( 7  1@   9  9 ( 9
(  (   "  

int i;
i = 4;


&  (     "     77  19 7    1@0   

Student theStudent;


    7  "  7 ( "  9   (        1@ )  (  
 7" " "*  7 "     1 7  )" * " 4  9 9  ( 
 I2 7 "   1 " I0 $ 9 9

theStudent = new Student();


  9 1@ 7 ( "      (    7  )  *     " 0 O 
9       1 7   " 0

/  $  0


 
 1 7   )74    ((*   "   I0I (    7  7
 1@ 8 

Student theStudent = new Student();
theStudent.marksOfMaths = 93;
theStudent.CalculateTotal();
Console.WriteLine(theStudent.obtainedMarks);


%I 9 8 " "   9   74           E )* 0

-/





   



using System;
namespace CSharpSchool
{
// Defining a class to store and manipulate students information
class Student
{
// fields
string name;
int age;
int marksOfMaths;
int marksOfEnglish;
int marksOfScience;
int totalMarks = 300;
int obtainedMarks;
double percentage;

// methods
void CalculateTotalMarks()
{
obtainedMarks = marksOfMaths + marksOfEnglish + marksOfScience;
}

void CalculatePercentage()
{
percentage = (double) obtainedMarks / totalMarks * 100;
}

double GetPercentage()
{
return percentage;
}

// Main method or entry point of program


static void Main()
{
// creating new instance of Student
Student st1 = new Student();
// setting the values of fields
st1.name = "Einstein";
st1.age = 20;
st1.marksOfEnglish = 80;
st1.marksOfMaths = 99;

-3





   



st1.marksOfScience = 96;
// calling functions
st1.CalculateTotalMarks();
st1.CalculatePercentage();
double st1Percentage = st1.GetPercentage();
// calling and retrieving value
// returned by the function

Student st2 = new Student();


st2.name = "Newton";
st2.age = 23;
st2.marksOfEnglish = 77;
st2.marksOfMaths = 100;
st2.marksOfScience = 99;
st2.CalculateTotalMarks();
st2.CalculatePercentage();
double st2Percentage = st2.GetPercentage();

Console.WriteLine("{0} of {1} years age got {2}% marks", st1.name, st1.age, st1.percentage);
Console.WriteLine("{0} of {1} years age got {2}% marks", st2.name, st2.age, st2.percentage);
}
}
}

4 9  1    1@ 7  "   )*4 9    4    8 7 
" 0 %4 9    " E8   ( 4  9      
(    1   7  (       9 90

$ (   (      1@ 7 ( " 4    (   1"0
  
 94 "      1@ 7  "    " 9 0 $ " (   "  (
 9 (

Einstein of 20 years age got 91.6666666666667% marks
Newton of 23 years age got 92% marks

/ 10  /  


 '5

= " "  4        7  7   0  7   9 4 <    
E8 7 ',,   ,,4 "    (    1  ,,\4 9    9 8 
0  (   7  1   @" 7  ("(4 004     
(" 10   -  7   1 ((    1 7  0 $   
   9  (    7   

-C





   




/ 10  +(
(  (  1    1  9       
(     ( 7 1  1  7  "  (@  7  (  
7      (
      1  7  "  (@
(  1  7         (   7      
("1 ("1 1       0 &   9      
0



= O1@ O    )OO*   9        8  " 7  ( 
  9  " 7 "        1 8   ("10  ;(4 9 
  " "   1 8    7 (          ("10

class Student
{
// fields
private string name;
private int age;
private int marksOfMaths;
private int marksOfEnglish;
private int marksOfScience;
private int totalMarks = 300;
private int obtainedMarks;
private double percentage;

// methods
public void CalculateTotalMarks()
{
obtainedMarks = marksOfMaths + marksOfEnglish + marksOfScience;
}

public void CalculatePercentage()


{
percentage = (double) obtainedMarks / totalMarks * 100;
}

public double GetPercentage()


{
return percentage;

-5





   



}
}


=7 "  I 8   1 7  9   74  9 1    (  1U   
 7"  7 7  1 7    ( 0

Q"   ((  7   (   "   4  74 "4  "4   
  0  (.  ( )(  1"  1    ( ;( (* 8 4  74 "  
 " "    " ("1       7 9       1 1 0 = 7
  7  I 8     (0   "   ((  7  (0

& (  
Q" " 1 9   7 9    7  "   ( 4 9  9  "  
"  7   9    "   17H   9  " (0    7
 "  (   "(( 7 7   ((    " 0

=    " 8 #    AA4 7    (  7 7  4 ("1   
)    "*    )   "* 9 7  8 7 9    (  7 

private string name;


 4      9" 1 8

// getter to name field
public string GetName()
{
return name;
}

// setter to name field


public void SetName(string theName)
{
name = theName;
}


2   9 "      (" 10  ;( 9  (    7   
7  E8 7  8    0

private int totalMarks;
public int GetTotalMarks()
{

/,





   



return totalMarks;
}

  "  4        " 7 E8     7 0 Q"    
8    17     "  " 7

private int marksOfMaths;
public void SetMarksOfMaths(int marks)
{
if(marks >= 0 && marks <=100)
{
marksOfMaths = marks;
}
else
{
marksOfMaths = 0;
// or throw some exception informing user marks out of range
}
}


 ("   "   7     9 7 7 "  " 1       (0
"4  (1   "   7  9       (7;   7 " 7 9 K  0
 (   1"  "(( 7        7 7 ((0 (   ;
    " "  4 9  (" (  7 7           9  7
 1 0

A & (  
    ; 7 ( 

<access modifier> <data type> <name of property>
{
get
{
// some optional statements
return <some private field>;
}
set
{
// some optional statements;
<some private field> = value;
}

/





   



}


+ I "   H ! (10 %I 7  9  ;( 9    (  7 

private string name;


$   7   (( 7  (   1    0 $ 9 ( 9

public string Name
{
get
{
return name;
}
set
{
name = value;
}
}


$ 7   ((  I!I   (  1         7 7  V W    V W 180
!  9  " (( I!I 9     (  7 I I0 =  1     
  ((     (   7 1" 9 7   "(( )7 .^!4 7
( .^ *0 & ((     74    8  ("1 9 
(   7  )  " 1*  ( 0       V W 184 9 9

name = value;

4 "   89       " ( 9  ((  0 = " ( 9 9 " "
(( 

Student theStudent = new Student();
theStudent.Name = "Faraz";
string myName = theString.Name;
theStudent.name = "Someone not Faraz"; // error


$ 7   ((4 9  ((   ;   0 $ 9 9

theStudent.Name = "Faraz";


 (    (( !    7    7    (4   9    V W
18 7  (( (  ::   " )9   89*0 =  ;   9 9 9

/





   




string myName = theString.Name;


 ( 9    (( !        7     (4    9 
  V W 18 7 (( ! 9 9 "     7  (  7  )::   4 
9      * 9 9 1       1 0
 4 9 ( 7   " 7
 ((4  8  9  ;      8 (((  9 (    ;0

   

theStudent.name = "Someone not Faraz"; // error


9    (   )7  "  "  *    7   (   
 7 0

Q"     7  7  7  V W   V W 180 =7 "    7 4   "    4
< 9  (  0  ;(  %  ((        U  4 
(         7  7  V W 180 Q"  9      V W4  V W 18
 "   0

private int marksOfMaths;

public int MarksOfMaths


{
set
{
if(value >= 0 && value<=100)
{
marksOfMaths = value;
}
else
{
marksOfMaths = 0;
// or throw some exception informing user marks out of range
}
}
}

&   $ ( (   


 (  I   "  U 4    "  89  
   ( 7 "      ( 7 (( "  9    ((
 &%$&Q " (( " 18 V W   ((    9 "  ((0

/'





   



 +O!I   9   V W   V W 18      
 2!% " ((         " 7  (  7 8

get { return name; }
set { name = value; }


 1@   7   9 (   70 "((    4 " 1@   ( 74
9 9" 9 H "((  "  " 4 9     )*     7 7 " 
  80 =  4 9      )* 7   9 8  1@   
 (0


class Student
{
string name = "Some Student";
int age;

public void Store()


{
FileSystem fs = new FileSystem();
fs.save(this);
}
}


$ (    (     )* 9 (    1@ 70

class Test
{
public static void Main()
{
Student theStudent = new Student();
theStudent.Store();
}
}

4 9 )*  4  7  "  9 1 (   (    )*   )*0
   4  (   "            7  7
 7      "   1 "   7 0

class Student
{
private string name;

/6





   



private int age;

public Student(string name, int age)


{
this.name = name;
this.age = age;
}
}

    " 9 9 "   4 9 "   1 (    9
 9     1 )7* 9  0
 4  " " 74 9   "  
 " "    1 )7* 9  1 ( "  (0

   ; "7"4 9     "  "0 =   " ( 9 :: 7 
 "  " 7 71 9 0

*  1  0 $


 
&  1 7    9    "(  9     14     1   
1@ 1  0  ;(4 7 "       7   "     1@ 7 "
  9    ( 7  7  9 0      7 1 9   0
 1 1    9       " 1@0  ;(4 7 "    
( !"1 7  " "  4   9 1       7  7     1@ 7
  9     70    1   1@  ( !"1 9 1  1  
1@0  1  7  "  89 

class Student
{
public static int phoneNumber;
public int rollNumber;
}


 1   9   7    7   1@0 % 8 "  
    E 

class Test
{
public static void Main()
{
Student st1 = new Student();
Student st2 = new Student();
st1.rollNumber = 3;

/-





   



st2.rollNumber = 5;
Student.phoneNumber = 4929067;
}
}

 "     ( !"1   9"   7    1@ 1" 9   7 
  1 0     "7" 9 ( 0 = 74  $% )*   % )*
  9  "  7      7   0     9 9 "  
 9 7       8   1@ 7    0 = ( 9 "  1 
"     ; 7  E     7"0 =     %   9" 8   
   7 " 0  1  "7" 9 " 9      " 1  1   1@
7  0 Q"  "  74 4 ((      " 9 9 1  17  
   7    0   "   8

static Student()
{
name="unknown";
}


&    1  9"   7   1@4 "   "    1   
  ((4 9 "     1 7   .  ;0   7 1  1 
  1 7  .  ;    1 1        (  (  7
 ;  7      1@0  7  7 EE)*  79   9  (

class Student
{
public static int phoneNumber;
public int rollNumber;

public void DoWork()


{
// legal, static method called in non-static context
MyMethod();
}

public static void MyMethod()


{
// legal, static field used in static context
phoneNumber++;
// illegal, non-static field used in static context
rollNumber++;
// illegal, non-static method used in static context

//





   



DoWork();
}
}


 ("  (     

 + I ("       "        1@    ( (  
8 "   ; 10
 + I   8   9        (( "  "      7
  0
 Q"      "1 7 1@      9 "   4   
 I 1   9      1 " ((4   9 "   O1@
O   7 ( 0

*1   1 $  


$        9 8  7 I(I   N" (   7  (0 N" (4 "
 (  (4  (   1 "0 7  (4 8 1@   4  ( 1
7 0

   
 "   ( 8  7 0 &  "   79  ((

 =           
 =   " (
 =  "  9  9     1@ 7    4   9 I  
 "0
   "       7  1@4 8    7" "   70
% "   ;(0

using System;

class Person
{
// field
private string name;

// constructor
public Person()
{
name = "unknown";

/3





   



Console.WriteLine("Constructor called...");
}

// property
public string Name
{
get { return name; }
set { name = value; }
}
}


=    1 4 9    (  7 4  ("1  " 9     7 9
  :" 8 9 :   (     1 4  9    ("1 ((  <9  (  7
0 % 8     9     E )*    9 "   

class Test
{
public static void Main()
{
Person thePerson = new Person();
Console.WriteLine("The name of person in object thePerson is " + thePerson.Name);
thePerson.Name = "Faraz";
Console.WriteLine("The name of person in object thePerson is " + thePerson.Name);
}
}


= "  4 9   1@ 7      (    7 ( 0 $     "
7 !   (   !  0  " 7  ( 

Constructor called...
The name of person in object thePerson is unknown
The name of person in object thePerson is Faraz

!    "   @"  9   9    7        7 
9   :" 8 9 :0 = 74 9 9   9 1@4 9 "    " 7  

Person thePerson = new Person();


  9  "  ""  ("10 =7 " 8 "  " ( 4    9" 1 1 
8  1@ 7 "  " 7  )"      7 " "*0  4 7   
 7  

/C





   



class Person
{
private Person()
{
}
}


  9" "    9

class Test
{
public static void Main()
{
Person thePerson = new Person(); // error
}
}


  " 9  7   1 (.4 00    8   (0 $  7 
 " 9 8  (0

class Person
{
private string name;

public Person(string theName)


{
name = theName;
Console.WriteLine("Constructor called...");
}
}


!94  1@ 7      1  1 (         "0

Person thePerson = new Person("Faraz");


=7 "  I 7     " 7 " 4  ( 9    ( (.  "
7 "0   9 9 9 1  8 " "  1@   9   (7    " 7 
"  0

/5





   




D:;1 $0 ! 
 
     " )(*   7  O1@  9       )*0
   "   1  9 " 1@  1  )  7 *0 Q" 
      ("   7 7  "  "   9 "   1@0  ;(4

protected override void Finalize()
{
try
{
Console.WriteLine("Destructing object...");
// put some code here
}
finally
{
base.Finalize();
}
}



    #    $      

 
     #  #%!     

4   
+"  @"  (( 7  "0    9  79  ((
=            1" (7;  9  c )*  0 =   " 9
 1@  1"  1 " )9 1   1"   " 1@*0 =   " (0
$   " 

class Person
{
// constructor
public Person()
{
}

// destructor
~Person()
{
// put resource freeing code here.
}
}


3,





   



&   7 74   (       "    )* 4 9 @" 9 1 0
+"   "  "    (  ( )  9 #  ((   7
"*0 =   7 AA4 (         . 0 +"
9 "   7    1  1@  0
 4 " (11 9 I  " 
"   )*   7 0

1 $    5

=  (1         9      " ( 1" 9  77  "1  
( 7 "  )(*0       0  ;(   (7   9

class Checker
{
// 1st overloaded form
public bool isDefaultValue(bool val)
{
if(val == false)
return true;
else
return false;
}

// 2nd overloaded form


public bool isDefaultValue(int val)
{
if(val == 0)
return true;
else
return false;
}

// 3rd overloaded form


public bool isDefaultValue(int intVal, bool booleanVal)
{
if(intVal == 0 && booleanVal == false)
return true;
else
return false;
}
}

3





   



=  8  1  9 7    9   +7"N")*0  " ( 7   
1 1"  77 7    ( 0  7 9 77    ( 7  ( 9 
   77   "1 7 (0 $ +7"N")*  4  ( 9  ) 
1 7  (   "1 7 ( 1  (* 9   7    " 0  ;(4 
" E )* 

Checker check = new Checker();
Console.WriteLine(check.isDefaultValue(5)); // calls the first one
Console.WriteLine(check.isDefaultValue(false)); // calls the second one
Console.WriteLine(check.isDefaultValue(0, true)); // calls the third one


1      (     (       " (0 
$% )*  7       (  5 77    7J   0!
98 +"   E+! 7  7 0

5
    
   "   ( ( 7 4 9     " 0

class Person
{
private string name;

public Person()
{
name = "uknown";
}

public Person(string theName)


{
name = theName;
}
}


!94 7 9   1@ 8

Person thePerson = new Person();


 7  " 9 1      9 :" 8 9 :0 =7 9   1@ 8

Person thePerson = new Person("Faraz");

3





   



    " 9 1      9 ::0 & "  4      
 "   " (   7 7;1   "   7 (;  9" 9 1
(" 7 9   " 77   7   )#"   9 9" ((  (  7
$% )*4 9 9"      "( 9 5 J*

?
 '( : % 0C'  ;
$ 9 (  1 7  (  (   4  ("  "     (   (
 (   0 =  "  ( 7  1    1    0
  7 "
7  " ( 1 )(   (*   4  " " 7  1 9"  1
  "  0 % "    "    E )*     +$8)* 

class Test
{
public static void Main()
{
int a = 3;
DoWork(a);
Console.WriteLine("The value of a is " + a);
}

public static void DoWork(int i)


{
i++;
}
}


 ( 9 " 

The value of a is 3

"  ( 7  1   (   +$8)*      1 0 &4     
 1  +$8)*       1  E )*0
 4   1  9     
  0 = 74 9  7    U  77      9    9 1     
9"   (   9    (0

 (   894 74 9     " ( 9 1 ( 1 7    7  7" 1
" 1 0
 4         9" 1 7 18 7    1 
   0     "      " 1   7       1
"   1 70

class Test

3'





   



{
public static void Main()
{
int a = 3; // must be initialized
DoWork(ref a); // note ref
Console.WriteLine("The value of a is " + a);
}

public static void DoWork(ref int i) // note ref


{
i++;
}
}


 ( 9    79  "

The value of a is 4

=   7  7 894  1 " 1   17 (      1 7 0  
(   " 890   " 7 (   1 7 "(" ("(0  9  1 ( 1
7 0
9 4 9 "   " 894         10

class Test
{
public static void Main()
{
int a; // may be left un-initialized
DoWork(out a); // note out
Console.WriteLine("The value of a is " + a);
}

public static void DoWork(out int i) // note out


{
i=4;
}
}


 ( 9    "

The value of a is 4

36





   



80  '( 
O1@  ( ( 1 7 0        ( 7  7   (   
"     0
 4 7 9     )9   1@  *   (    
9     4     77 9" 1 1 7    1    
  0

class Test
{
public static void Main()
{
int [] nums = { 2, 4, 8 } ;
DoWork(nums);
int count =0;
foreach(int num in nums)
Console.WriteLine("The value of a[{0}] is {1}", count++, num);
}

public static void DoWork(int [] numbers)


{
for(int i=0; i<numbers.Length; i++)
numbers[i]++;
}
}


 ( 9 " 

The value of a[0] is 3
The value of a[1] is 5
The value of a[2] is 9

4 9      (  ) "* 9  "0 $ (     +$8)* 4
9    )7*     7  0  4 9 (     7 0 &  "("
"4  +$8)*          ) "*   98  "      
( )     " (*0

*    0   ! 


& 7   @"  (       1@  0 =  (1    1@ 9"    
     7 

new Student();


3-





   



 1        0 = 9   1@ 7 "   9"   7  (    0 &
1@  " 1  1 1  9    7   (  0 4   1  4 
9 "  1@ 9    1 1  1 1  7   0 ;(  (
7     " 7  1@ 8

int pc = ( new Student(87, 94, 79) ).CalculatePercentage();


=  1   4  9 1@ 7  "       " )*     0
 9 4 " 7  1@ 9 1 1  1 1  @" 7  
" )* (  ;" 0 = (  9 I  " "  9 "  0 
1      

Student theStduent = new Student(87, 94, 79);
int pc = theStudent.CalculatePercentage();
theStudent = null;


$   "  "    1@ 1  9 1  7         7
( " ;(0 $ " 9

Student student1 = new Student("Faraz");


 9 1@ 7 ( "      (           7  " 0 % " 8
  1@          7  " 0

Student student2 = new Student("Newton");


!94 7 9 9

Student student3 = student2;


 9 7  " ' 9   (    "  )!9 *  (  1 " 0
  1
"    " ' 9 1 (     "    1  8     1@0

"  3(:1 ';


 "  1@

  
"   "  1@




" ' d 1@d

3/





   



!9 7 9 94

student1 = student3;


 9   (       1@ )!9 *4     7 "  )* " 7 0 =   
7 "   9 1  1 1     1   7   0

"  3(:1 ';


 
 "  1@  

  
  
"   "  1@




" ' d 1@d


=7 " 9   7   7   4 "     "4 9   89  0

student1 = null;

33





   


#$  %&
' ($ 

 &

 9 9  1" 7"   1@   7" 8      ((  0 $ 9
 1 1"   " "    7       9 9   9 "    9 
"((   0 $ 9 (    ;(   1@     9 9  9
((   9 ((  (   0 $ 9 7    1 "    9
1; 4 " .1;    (.    98  0

$  
2    " 7   1@   ( 4 " 9      1" "1  
; 10 "1   (( 7  " ) (  4      *   1   1
"  77  ((  9"         " 0 ; 1 7  "  I
(   1 ;  )  *  9    0 "1  O1@ O     "
   1 "  "(  19 77  4 9 ; 1    1 "1. 0 
( 7 "1.     ;   7"     =    "1.( 0

    )     "1.(*    14 (   "( 0      
7"   7  1    ;     9 9    "14 4      0

7 
 

4 5
  4 5
  4 5
 

3C





   



 ;(
*$(
A (  "1
 !
. (   
 !
 (  

" "

 
 8 
  5
#$ "
%& #$ 
 
%& #$ "'
%&
#% "& #% "& #(
!%& 
#"

+
,
- )*!



=  7" 1 4 9   "  2E% )2 7 E  % "*    9 =  0
4
(   1  9 4     "    "1.0 & 1  ""   
7"  4 9 "1. ( (7 7"  0 4 9 "1.     4 9  -
 .    . -0

=7    )"1 *     & )1 *4   9"    ( 7      1 )74
4 ((* 7  &        1 );( 7  (  1* 7  &0
  1 7  1        "1.4 1"    1  1  "1.0 &4
       4 -  -  (    9   "1.   ( 7 1 0
)=7 "      4  I 94   9   9 9 (       79 
 *

$   
7 9    (  4    8.(  1"     

 4 8 #       AA4 9        0 E"(    7  
 9  0
  O1@  7     (  (  " 1  7    
 )   0! 798*
 = 7           70

4 "(    7  7  9   )   # *0 $ 9 8   7   
    0 "" )"*        ) ( *  7     1  0


 &             
 '    $  



       
       $ 

35





   



(
 $   
 "   I I (      0 "(( 9     "  9  7
 !"14    O74   9  (   ((0      
K&)* 9 "   "    7  " 0

class Student
{
// private Fields
private int registrationNumber;
private string name;
private DateTime dateOfBirth;

// Student Constructor
public Student()
{
Console.WriteLine("New student created. Parameterless constructor called...");
}

public Student(int registrationNumber, string name, DateTime dateOfBirth)


{
this.registrationNumber = registrationNumber;
this.name = name;
this.dateOfBirth = dateOfBirth;
Console.WriteLine("New Student Created. Parameterized constructor called...");
}

// Public Properties
public int RegisterationNumber
{
get { return registrationNumber; }
}

public string Name


{
get { return name; }
set { name = value; }
}

public DateTime DateOfBirth


{

C,





   



get { return dateOfBirth; }
set { dateOfBirth = value; }
}

// Public Method
public int GetAge()
{
int age = DateTime.Now.Year - dateOfBirth.Year;
return age;
}
}


 "   1    (0 $   7   (  74   ((    
  "   7  " 0 $   7  9  "  7   8  (  
  8  (0 !  9     7    V W (( 7  !"1  
9   9   " 7  "       !"1     1   " 
 "0

&   9   8  K&)*  ((4 1"  0   7    (( 
  "((  1  7  <   " 7 7    7 " <(  
0
 4  8     K&)*   0

!94  "      "      "  4 1" 9   1
8 8 7 77  "1@    7 "   8   ( 0

class SchoolStudent : Student
{
// Private Fields
private int totalMarks;
private int totalObtainedMarks;
private double percentage;

// Public Constructors
public SchoolStudent()
{
Console.WriteLine("New school student created. Parameterless constructor called...");
}

public SchoolStudent(int regNum, string name, DateTime dob, int totalMarks, int totalObtainedMarks)
: base(regNum, name, dob)
{
this.totalMarks = totalMarks;

C





   



this.totalObtainedMarks = totalObtainedMarks;
Console.WriteLine("New school student created. Parameterized constructor called...");
}

// Public Properties
public int TotalMarks
{
get { return totalMarks; }
set { totalMarks = value; }
}

public int TotalObtainedMarks


{
get { return totalObtainedMarks; }
set { totalObtainedMarks = value; }
}

// Public Method
public double GetPercentage()
{
percentage = (double) totalObtainedMarks / totalMarks * 100;
return percentage;
}
}


 "      "   1 "    (0

class SchoolStudent : Student


 "       1 7  "  0 =  4     9
1  (  7 )E84 O1 E8   ( * 9  (  
((4 9  " )  9" (     9 (*        
)K )**0  94 7 1"    )(*  " 7 " "  0 %
" 9 "     E )* 0

// Program to Demonstrate Inheritance
class Test
{
static void Main(string [] args)
{
Student st = new Student(1, "Fraz", new DateTime(1980, 12, 19));
Console.WriteLine("Age of student, {0}, is {1}\n", st.Name, st.GetAge());

C





   


SchoolStudent schStd = new SchoolStudent();


schStd.Name = "Newton";
schStd.DateOfBirth = new DateTime(1981, 4, 1);
schStd.TotalMarks = 500;
schStd.TotalObtainedMarks = 476;
Console.WriteLine("Age of student, {0}, is {1}. {0} got {2}% marks.",
schStd.Name, schStd.GetAge(), schStd.GetPercentage());
}
}


=  E )* 4 7 9   1@ 7  "   )*   (       7 "  4
 9   1@ 7  "   )*0   9 "  (  " 
   4 9   " 7  7 " ((    (   4    ( 
7 "  )*0

!  9  1    (( !   +O7 )7   "  * 1" 
"      7  "  4 "     ("1 (( 0 $ 9 ;"
 1  (4 9   79  "("

New Student Created. Parameterized constructor called...
Age of student, Fraz, is 23
New student created. Parameterless constructor called...
New school student created. Parameterless constructor called...
Age of student, Newton, is 22. Newton got 95.2% marks.
Press any key to continue

 "(" 7  7 9     ;(4 1"   "(" 9 9   "  1@0 
 (  " 7 "         " 7 "   0

New student created. Parameterless constructor called...
New school student created. Parameterless constructor called...

   

$  
$ 9     "1. )" *4  ( 7     1. )" * 1
    7   "        " 7  "1.0 "(( 9 9 9   " 
   " 7  "  0  4 9        9  1 89 
" I    "    8    8

public SchoolStudent(int regNum, string name, DateTime dob, int totalMarks, int totalObtainedMarks)
// : base(regNum, name, dob)

C'





   



{
this.Name = name;
this.DateOfBirth = dob;
this.totalMarks = totalMarks;
this.totalObtainedMarks = totalObtainedMarks;
Console.WriteLine("New school student created. Parameterized constructor called...");
}


  " 8  (  7 7  1 "     7  1  1 
)" *     "   "   ((0 !94 9      E  

static void Main(string [] args)
{
SchoolStudent schStd = new SchoolStudent(2, "Newton", new DateTime(1983, 4, 1),500, 476);
Console.WriteLine("Age of student, {0}, is {1}. {0} got {2}% marks.",
schStd.Name, schStd.GetAge(), schStd.GetPercentage());
}


=  E )* 4 9   1@ 7 "  "   (  "    ( 
 4    (  7  " 0
 "(" 7  ( 

New student created. Parameterless constructor called...
New school student created. Parameterized constructor called...
Age of student, Newton, is 20. Newton got 95.2% marks.
Press any key to continue.

    "  9   "("U 7  (  " 7  1. )" * 
     (  " 7  "1. )" *   0 = 9  
(   1@ 7  1  17      "1.0 !94  "   " 
(  " 7  "  0


class Student
{
...
/*public Student()
{
Console.WriteLine("New student created. Parameterless constructor called...");
}*/
...
}

C6





   




!9 9 9   (  (4 9   

No overload for method 'Student' takes '0' arguments

 (  " 1  7    "  )(*  " 7  1.0 $ " 1
  H

$  9' E 

    0 $  E


 2(

'
$  ;(    " 7  1. "   89 10 1 " 1 " 9 
 "  )  "   * 7   I I ( 8

class SubClass : BaseClass
{
SubClass(int id) : base() // explicit constructor call
{
// some code goes here
}
}


=   1 4  (  " 7  "1. )"1*  ;(    (
 " 7  1 0 $     (  " 7  1. "  1
894 8

class SubClass : BaseClass
{
SubClass(int id) : base(id)
{
// some code goes here
}
}


!94   " 7 "1) * 9 ;(    " 7  1. )*  8 
  " 0 % " ( 9 " "    0  8    9     
 "   8  8 8

public SchoolStudent(int regNum, string name, DateTime dob, int totalMarks, int totalObtainedMarks)
: base(regNum, name, dob)
{
this.totalMarks = totalMarks;
this.totalObtainedMarks = totalObtainedMarks;

C-





   



Console.WriteLine("New school student created. Parameterized constructor called...");
}


  " 1    (  " 7  1. )" *4     
7    7   1.I (  "0

public Student(int registrationNumber, string name, DateTime dateOfBirth)
{
this.registrationNumber = registrationNumber;
this.name = name;
this.dateOfBirth = dateOfBirth;
Console.WriteLine("New Student Created. Parameterized constructor called...");
}


   ( 4   7  !"1  (    (      VW ("1 ((0 4
  9  9   !"1 7  " 4 ;( 9     "0 1 7 1  
 0  E )*  9" 1 8

static void Main(string [] args)
{
SchoolStudent schStd = new SchoolStudent(2, "Newton", new DateTime(1983, 4, 1),500, 476);
Console.WriteLine("Age of student, {0}, is {1}. {0} got {2}% marks.",
schStd.Name, schStd.GetAge(), schStd.GetPercentage());
}


$ 9 "  (4  79  "("  (    


New Student Created. Parameterized constructor called...
New school student created. Parameterized constructor called...
Age of student, Newton, is 20. Newton got 95.2% marks.
Press any key to continue

Q"   7  "(" 1   . 7  (  " 7 "  )1.*    
  (  " 7 "  )"1.*  4    ((( "4 9 
; 9 9 9   0 =  ( (   4    (  7 " 0
!  " 9 9 1 7  "1.I  "  4   " 7  1. 
9  17   " 7  "1.0


 !"$   (
$  !"  #  !)) 
   !))$  

C/





   



&   / 10 
= " "  4  !"1   (         VW ((    " 7 
"    7   !"1 "  0 =  1 (1  9   7 
7 ) !"1*  " "  4 1" 9    0  (   ( 
7 @" 7 0 ( 1 7    1              
"1.0 2  9 I 1 1    ( 1 " 1@ 7    7      4
 ( 9" (      0

"(( 9     & 9  (  +$8)*

class A
{
protected void DoWork()
{
Console.WriteLine("DoWork called...");
}
}


=7 9    +$8   E )*  7   4  ( 9    0

class Test
{
static void Main(string [] args)
{
A a = new A();
a.DoWork();
}
}


$ 9   ( 4  ( 

'CSharpSchool.A.DoWork()' is inaccessible due to its protection level

"4 7 9    4  9   &       +$8)*     10

class B : A
{
public B()
{
DoWork();
}
}

C3





   



 9      7   &     +$8)* 7  1. )&*    "0
!94 9 9 9

static void Main(string [] args)
{
B b = new B();
}


 " 9 1

DoWork called...
Press any key to continue

= 9  9   ( 1 7      "1.0 !     9   9

static void Main(string [] args)
{
B b = new B();
b.DoWork(); // error
}


$    ( 1   9  7  7  "1.0

$&     
/ 10 
=   94  (     7 9  1 )74 ((   *  1


 =       4 
 =    (@4 
 =   "1. 7      0

 4 (     8 I( O   I4 004  (    0

$ 
9' 
 4 7 "  I 9  "   1   1   4 "  8  9   890 ! 
   7   0

sealed class A
{
...

CC





   



}


=7           9  &

class B : A
{
...
}


 ( 9    79  

'CSharpSchool.B' : cannot inherit from sealed class 'CSharpSchool.A'


 !" $     (
$      

 ! 
 E $  0


  
=  )   0! 798*   ( )4 ""    7*  (   7 
O1@  7     (0   (   9.        7"  
         0! 7980  O1@   ; "7" 9   
(( )9 9  1"  *4   7  7 ( O1@     ( 7 1@0  O1@
  79  

E ! +(
F")O1@* ( 9 1@ 7 F"0  7" (   
"(( 7  F"4  4  9 " " 7 1
7  (     1@0  " (4 19 8 
 (70 +   "      7 
F" 7  1@0
 F")O1@4 O1@*   1  ;(4    0
K
)* "     7  "  1@0
K ()* "   ( 1@  (   ; " . ( 7 
"  1@0
 7 F" )O1@4O1@* "  " 7 1  7  ( (     1@4
9 "  70
 )* "     (  7  1@0 +   "
     (     (  7  " 
1@0
(  )*  (  " 1   1     
7   "0     1 % 17  " 
1@   1 K1 0
( E19 )*    9 ( 7  "  1@0 & 9 (
    ( 7      7 )* 7  "  1@0
C5





   




  (   1@ 89 9 (   0O1@    0! 798  1
)%*0

&
' ($ 
=     (  "   9     1@   (   "0 
7 (  9  ( "  .1@    " )8 74 70004 9000* 7  1@
  (   "0    (  9  ( 9 4      
 1@0   (  9  ( " ((     1  0

E+! )E7 + ( !98* ;(  :(   1 7   (  77 
(   7     1   0 ( 9   7    1
 9"   9 (7 (   ( 0:

A  $ 0 0 $   '(0  0  $ ! 0$
 '( 
7       7 ((4 9   "     7  7  1 (  
 1@ 7    (0 %   & 1   1   

class A
{
public void MethodA()
{
...
}
}

class B : A
{
public void MethodB()
{
...
}
}


     9

A a = new B();

  7  7 ( &     1@ 7 ( 0 =   9     1@ 7 (   
1@ 7 ( & )9  F" (1     "1.( 7 &*0 !94   (1  9

5,





   




a.MethodA();


"      9

a.MethodB(); // error


&" 9    1@ 7 (  )     7  7 ( &*4 9      1 7 (
    ((  (   &    0

A  $  $ $  $7  $* E


 
= " (   " 7    +9)*  9  (   

class Shape
{
public void Draw()
{
Console.WriteLine("Drawing Shape...");
}
}


$       7  ( 4 9       +9)*0

class Circle : Shape
{
public void Draw()
{
Console.WriteLine("Drawing Circle...");
}
}

4 9    +9)*  9    "  1  (     0 !94 7  "
E )* 4 9 9

static void Main()
{
Circle theCircle = new Circle();
theCircle.Draw();
}


I +9)*       ( 9 );(* (

5





   




Drawing Circle...

!   ( 9    9    +9)*       +9)*  7 ( 0
=7  " E )*  9 9

Shape theShape = new Circle();
theShape.Draw();


(I +9)*       ( 9 (

Drawing Shape...

5  $ $ E5 


5 9'  
!94 7 9 9      +9)*  7  (     4 9    8  +9)*
   ( )1*   "    +9)*     )"1*    0

class Shape
{
public virtual void Draw()
{
Console.WriteLine("Drawing Shape...");
}
}

class Circle : Shape


{
public override void Draw()
{
Console.WriteLine("Drawing Circle...");
}
}


!94  " E )*  9 9

static void Main()
{
Shape theShape = new Circle();
theShape.Draw();
}

5





   


 9   "  7  7  1 ( )(*  7   1@ 7  "1 ( )*    
+9)*  " 0 & 9      +9)*  7 (         
+9)*   8 "  (4  ( 9      ((  ) 7 * (  
  )4   (  1@ 1  *4 4  9 (( /
%   *  

/   9   1@ (  I" I   9 +9)*   " 0  (" 
 ((U 9 9   77  (   7   9       " 
 1   "1.0 $ "     "   1.( 7 4  ( "  "
1@ ( 7  1  1 ( 7    9 7    0 $ 9 ( 
1  (4  " 9 1

Drawing Circle...

&"4 9   +9)*  "   7  7 ( (4  % 9    1@ 
1  ( 7      +9)*  7   0

$ 8     1   9 9 9     ((  "0  8  
 "4 9 9    1     1 " ((0 =   94 9 8 
   "1.    9       "    1 0  8  
   4 9  "   9  1     (   "    1
0


  !" 
 $(
*  
+

 # $ 
*$!))+,$!)) (
  
   
  
 
    
    
   !"   $   $
  
  

Q"  1 9   9   ( " ;( )7 (    *4  1      
(   7  ( "   9 1@  7  )(* 0

Shape theShape = new Circle();
theShape.Draw();


Q4   (1 7  (   "    (" 4 1" ""  (   1 
  1@ 7 9   7  9" 1 7    " .0

"(( 9 7  9       "  9     (      
+9)*      9 (7 (  0

class Rectangle : Shape
{
public override void Draw()
{

5'





   



Console.WriteLine("Drawing Rectangle...");
}
}

class Curve : Shape


{
public override void Draw()
{
Console.WriteLine("Drawing Curve...");
}
}


!94 7 9 9  E )*   79

static void Main()
{
Shape [] shapes = {new Circle(), new Rectangle(), new Curve()};
Random random = new Random();
for(int i=0; i<5; i++)
{
int randNum = random.Next(0, 3);
shapes[randNum].Draw();
}
}

4 9      7 ( (     1@ 7  4     "    0
!;4 9 "           "1 19 ,    )1 ,     " *0 $ "
     "1    ;   (     +9)* 0 !94  9  
(  " 9 ("  ; 7 ( 9 1 "    +9)*  7 9 "1. 7 (
9" 1   "     7  (0 $ 9 (   "  1  (4 9 9 
 77  "(" 9  " 0  ;(4 9 = ;"  1  (4 =   79  "("

Drawing Curve...
Drawing Rectangle...
Drawing Curve...
Drawing Circle...
Drawing Rectangle...
Press any key to continue

56





   



$9' 
"((4  "  4 9  I 9      +9)* 4 1" 9      +9)* 4
9 9  H = # 4 9  I  0 = AA4   7 9 8     1   "4  
(10 "4   "  89 9  8      .          9
9  I 9   " ((0 % " 7   (     

class Shape
{
public virtual void Draw()
{
Console.WriteLine("Drawing Shape...");
}
}

class Circle : Shape


{
public new void Draw()
{
Console.WriteLine("Drawing Circle...");
}
}


!  9 8  +9)*    9  9 89    ((0 = "  9
9

Shape theShape = new Circle();
theShape.Draw();


$ 9 (   "  1  4 9 9   79  "("

Drawing Shape...

 4 9 8  +9)*       94  ((  ((     +9)*
 7  (   0 =7 9  I 8  +9)*  9  9 894 9 9  
79  9    ( 

'CSharpSchool.Circle.Draw()' hides inherited member
'CSharpSchool.Shape.Draw()'.

 8  "  1    (  4     890 O9   9
890

5-





   



'(  $ ! EA(E 4E 
(     I8   1@ 1  8I  I    ((  ( 7  1@I0 = 4 "  
 1@        7  1 9  ( )"(. *  7  ( 9
 1 )9 . *0

2(.   (4 7   (4  9     7  7 (  (  7   1@ 7
 (0

Parent theParent = new Child();


O   4 9 .   " .7   ;(0  " .74 9    9  ;( B  4
70    79    7 

Shape [] shapes = { new Circle(), new Rectangle(), new Curve() };


$ 4     "   "1. 7 ( 0 !94 7 9 9   7    
1@   (  9  7  7 (  4 9  I @" 9

Rectangle rect = shapes[1];


= 4 9    ;( ((    

Rectangle rect = (Rectangle) shapes[1];


         ((  ( 7  1@ 7 (    )9 9     
*4    9 . 0

&4   9 .   1 " "7"   7 9 (  9

Rectangle rect = (Rectangle) shapes[2];


  (ST     1@ 7 ( "  9   1      (4  % 9"
  79  ;(  " .

System.InvalidCastException: Specified cast is not valid.

$  9'  


 8  " . ( 7  1@4 "  "       890  (  ( 7 
1@ 9    (   "  " 7   .1U 94  "  70  ;(4

Console.WriteLine(shapes[1] is Rectangle);

5/





   




9" (  "     $ 94 9

Console.WriteLine(shapes[2] is Rectangle);


9" (  7     9 90 $  "   (  8  "  ( 7  1@
17 ((  9 . 0

Shape [] shapes = { new Circle(), new Rectangle(), new Curve() };
Rectangle rect=null;
if(shapes[1] is Rectangle)
{
rect = (Rectangle) shapes[1];
}


&  4 9   "   (  8  " . ( 7  1@0   ( "  "
7  1@   .1 94    1@   (7 ( 

Shape [] shapes = { new Circle(), new Rectangle(), new Curve() };
Rectangle rect = shapes[1] as Rectangle;
if(rect != null)
Console.WriteLine("Cast successful");
else
Console.WriteLine("Cast unsuccessful");


&"     (7  7"  4  @" 8  "  ( 9     4 
  1@   (7 (0

72AE 2
  ( 7   1;    " .1; 0 ;  9 " (  1 (  8 1@0
"((4 9      1   

int i = 5;


9 9 9

i.ToString();


 ( (      7  O1@    1; )*  ( 7    " )-*  
1@0 =     )*       7  O1@  9  1;  ( 7   
"0 =    9 

53





   




int i = 5;
Object obj = i; // implicit boxing
obj.ToString();


Q"     1    1;   ( ((     "  I    9

Object obj = (Object) i; // unnecessary explicit boxing


O    4 " .1;   ;(   7 1@ (  " (0  79    9 9
" .1;   (   

int i = 5;
Object obj = i; // implicit boxing
int j = (int) obj; // explicit un-boxing


%8 9 . 4 " .1;   1 " .7   9  = ;(  " 0


   #   # $
        
  

' # ,  #  
  -   - 
* +  - 

.    $  -   ' #$  
  $ 
  #$
 $  $/      
 
  - !  -     

5C





   


"*    +  +,  

 % 
  

 &

I    7 7" @ ( ""4  " 4 K1    ! 0 $
9      1  0

*    :  ;
""4     1  " 894  9 1@0 ""      
4 1" 9  79  ((

 & "  "7" 7   (   "    8  4  4  (0
 & "  7 " (4     9  7 7  (0     "" 
   8   (   1 "4  4 1 8   (0
 & "     " );( 7  ."   "*4 74   
(( @" 8  0
 %8  " (4 "       4    1  0
 & "  (   70
 %8    (  4  "   (   7  0O1@ 0
 =   7  "  1  9   9" "   9 890

E 7  0! 798 ( 8 0= ' )7  *4 0+"1 )7 "1*4 0 )7
1*4 0 )7 1*4000  (    "0 $ 8(   4  "   77 
" 1     0

40  
& "  7  @" 8  4 "   " 890 "((4   9  (( 4 9    
 (0      (   9 (4 9 (     "0

struct Point
{
public double x;
public double y;

public Point(int x, int y)


{
this.x = x;
this.y = y;

55





   



}

public override string ToString()


{
return "(" + x + ", " + y + ")";
}
}

4 9     "   0      9 ("1 74 ;   4  (   
7        0 $ (   ("1  "      7  (    9
     )*  7  O1@ 4   " (   1 (   "  
 0$% )*    E )* 0

    $  
& "  1      9

 2   9 89      7" ."   "0
 2   9 89      "  " 7   "0
 $" "   9 890

& 9    4 9   (   ."   "   "   7 9    4 
( 9    0  ( ( (   7" ."   " 7  "
9    7 7  " 9  7" "0 =  79  E )* 4 9   
  "   1      9

class Test
{
static void Main()
{
Point pt = new Point();
Point pt1 = new Point(15, 20);
Point pt2; // instantiation without using the new keyword
pt2.x = 6;
pt2.y = 3;

Console.WriteLine("pt = {0}", pt);


Console.WriteLine("pt1 = {0}", pt1);
Console.WriteLine("pt2 = {0}", pt2);
}
}

,,





   



 "(" 7  ( 

pt = (0, 0)
pt1 = (15, 20)
pt2 = (6, 3)
Press any key to continue

4 9         1@0  7   )7  1 (*     "  9   
7" ."   " )(  1  (* 9    70 "4  7  
)(*  (   ),4 ,*0      )7  1 (*     "   9 89    "
)"14 "1*  "0  (  )(*    9  (7 "   " (   )-4 ,* 
  0   1@ )7  1 (*   9" "   9 89 )8 ( 
(*0 !  9 7     7 7 ( 17 "   )   0$% )* *0 7
"   "  9"  9 894   7 " 1 ;(  0
 4    )(*
(  "  )/4 '*0 !  9 9

Console.WriteLine("pt = {0}", pt);


  7

Console.WriteLine("pt = {0}", pt.ToString());


 0$% )* ;(   4 1"   9       )*   "   "4 
( 9 (    )*  9  ;(     

Console.WriteLine() method.


% " ( 9 " (    " "    7  "0 =7 9  I     7  7 7
  

,





   




static void Main()
{
Point pt2;
pt2.x = 6;
// pt2.y = 3; // line 1

Console.WriteLine("pt2 = {0}", pt2);


}


 ( 9      I  I

Use of unassigned local variable 'pt2'

!94  " 8  7 7  (  (    (  ("1 ((   0

struct Point
{
private double x;
private double y;

public Point(int x, int y)


{
this.x = x;
this.y = y;
}

public double X
{
get { return x; }
set { x = value; }
}

public double Y
{
get { return y; }
set { y = value; }
}

public override string ToString()


{
return "(" + x + ", " + y + ")";

,





   



}
}


!94  "        7    9" "   9 89

static void Main()
{
Point pt2;
pt2.X = 6;
pt2.Y = 3;

Console.WriteLine("pt2 = {0}", pt2);


}

4 9        7   )(*4    7 "   ((   
(  "     0$% )* 0 $ 9   (  (4  (  
 

Use of unassigned local variable 'pt2'

$     7 " ((4 1" 9   (  (  H = 74 9
     " 9"  9 894 9 " 7    7 ;(4 9" "   
((  0     "  I      "  " 9"  9 89 "   
7  ("1 ) 1  "*   ;(  0

 4  "   7   ."   "   "

struct Point
{
public double x;
public double y;

public Point()
{
x = 3;
y = 2;
}

public Point(int x, int y)


{
this.x = x;
this.y = y;

,'





   



}
}


$ 9   (  1  (4  ( 

Structs cannot contain explicit parameterless constructors

4  (       7  ( ) ." *  "   "0


     !))      *0+1
   
!)) 
    -   -  !))    !" 
     
   $ (
  
  
 

  ?
'( 
$ 9 9    " 7 "   ".( "  ( ( 9 (  "  
  7 0 $ 9 "    "  9 7  0         E )*
 

class Test
{
static void Main()
{
Point pt = new Point(19, 12);
Console.WriteLine("Before calling ChangeIt(pt): pt = {0}", pt);
ChangeIt(pt);
Console.WriteLine("After calling ChangeIt(pt): pt = {0}", pt);
}
static void ChangeIt(Point point)
{
point.x = 6;
point.y = 11;
Console.WriteLine("In the method ChangeIt(pt): point = {0}", point);
}
}


$      )(* 9 )54 *       =)*4 9 7   7 
 0 $  (     174 7       =)* 0  "(" 7  ( 

Before calling ChangeIt(pt): pt = (19, 12)
In the method ChangeIt(pt): point = (6, 11)

,6





   



After calling ChangeIt(pt): pt = (19, 12)
Press any key to continue

$    7  "("   " 7           ) =)**4 1" 
    7 18      "4 9 (   " .    E )*  7 
 =)* 0  "((  7  "    " ( 1 0

  
 "      (   7"   AA4 1"   # 0  "((  "  "  
 " 890  " 4 8    ""4  9 "  7  9 (0  " (
    7    0       "   9        "
 70  "   7   ( 8  4 4 14d );(   (*0

$0   


7 9      7 9  7    "  " 4  " 7   9 9 
 "    7 (0 "(( 9   (   $ 9 ;( ( 7 (  9 
"   77  8 9  "   7 0 = N9 (4 9 9  "    
 7 7<7   1 7 4 (4 4  7 0 % " 9  7"   8   
9 " (    7  7" 0

public void Sort(string criteria)
{
switch(criteria)
{
case "by name":
// code to sort by name
break;
case "by type":
// code to sort by type
break;
case "by size":
// code to sort by size
break;
case "by date":
// code to sort by modification date
break;
default:
throw new Exception("Invalid criteria for sorting passed...");
}
}

,-





   




=7  "   (   7<7 1 4 9 (  7"     :1 : 8 

Explorer explorer = new Explorer();
// some code goes here
explorer.Sort("by name");

 ;(    7        )* 0 & 9 (    " :1 :  
)* 4  (     9d 18   9 8 (((  )  1 *0
"4 7   9

explorer.Sort("by extention");




explorer.Sort("irrelevant text");


 ( 9   ( 1"  9 9  ;(  " 4 9 7  " ((4 
  ( )$ 9   1" ;(       0  94 @"    
( 9  ;" ((     7     "  (   (   )*
*0  " 1    8  "  (.       " . (0
 " (   " 7  ( 7  (10

A   :;
 "   7    "    " 890   "  7 )    * 
( "    I4I0

enum SortCriteria
{
ByName,
ByType,
BySize,
ByDate
}

4 9   7    "  4 9    7"    !4  (4
   +0 !94 9  7 " )*   (   (  "  0

public void Sort(SortCriteria criteria)
{
switch(criteria)

,/





   



{
case SortCriteria.ByName:
// code to sort by name
Console.WriteLine("Files/Folders sorted by name");
break;
case SortCriteria.ByType:
// code to sort by type
Console.WriteLine("Files/Folders sorted by type");
break;
case SortCriteria.BySize:
// code to sort by size
Console.WriteLine("Files/Folders sorted by size");
break;
case SortCriteria.ByDate:
// code to sort by modification date
Console.WriteLine("Files/Folders sorted by modification date");
break;
}
}


!  9      7" "   9d4 1" 9   (1  ( " .9
  1 8        ( 9 8    ( 0 !94   
  )* 4 9   (     7   " 7 ( 4 9    8
 (" 7 7  9 7"  4   (    (  8 7  0 $ 9  
)*  

Explorer explorer = new Explorer();
explorer.Sort(SortCriteria.BySize);


&  4 9       7     (    "   )* 

Explorer explorer = new Explorer();
SortCriteria criteria = SortCriteria.BySize;
explorer.Sort(criteria);


$ 9 (   "  1  (4 9   79  "("


Files/Folders sorted by size
Press any key to continue

,3





   



=    4 "  7    "7"  "  8  7  98 )" 4 E 4d*4 
7    )# "4 1"4d*4   ( ) =4 2+*4 7 (  )O 4 $O 4
$4 &(( *4 0

1      


 "     "   "  (   77     0  "   ( 7 
 "  1     ( )00  4 14 *0  7" (   0 = 74 9 9  
 " 4      "    "   7 0
 4  " 
 " 4  " 7 !  ,4  " 7  (  4  " 7       " 7 +
 '0 $      "  18     " 1 ((   ((( 0

static void Main()
{
SortCriteria criteria = SortCriteria.ByType;
int i = (int) criteria;
Console.WriteLine("the integral value of {0} is {1}", criteria, i);
}

4 9      7  )  *4 (.        (   "  
 0$% )* 0  "(" 

the integral value of ByType is 1
Press any key to continue

Q"   7  "("     " 7 0 (  0 &   9 9 (  
 "  7 )*4  (       ) (*     " )*0 $   7 
 " 7   "  7 ;( 9 7   9  " 4 8

enum Temperature
{
BoilingPoint = 100,
FreezingPoint = 0
}


!94 9 9   (   " 7  ("0    ("0  4  9
(    "     7" " )  7        1    *0

int i = (int) Temperature.BoilingPoint;
Console.WriteLine("the integral value of {0} is {1}", Temperature.BoilingPoint, i);


$ (

,C





   




the integral value of BoilingPoint is 100
Press any key to continue

   79   "
enum Days : byte
{
Monday = 1,
Tuesday,
Wednesday,
Thursday,
Friday,
Saturday,
Sunday
}

 9   7    " 7 +0 !  9    " 7   E 0
 4 
  " 7 "     9" 1 "    7  ) 4  7 "4 ' 7
$      *0 &4   9 (7  "   ( 7   " )+*   1
  7  7"   (0 !94  ( 9 "  1 (  (     0

enum Days : byte
{
...
}


=  E )* 4 9  (     " 7  

static void Main()
{
int i = (byte) Days.Tuesday;
Console.WriteLine("the integral value of {0} is {1}", Days.Tuesday, i);
}


 "(" 

the integral value of Tuesday is 2
Press any key to continue

 4  "   7 " (0         8   (    1
8   ( 7  " )1 "*0

,5





   



,  

  
E         ( 1 7  ( 9 9       0!
   0 0! (   9 K1      0  K1    (
 "    18"    9.(    8( 8 7  " .7  1@ )1@  
   7  1   7 * 1 8    I 1@I0  K1    8 1 
0! "   "          1@ 7 0
7 .    7   1@ )17     1@ 7 *4  1 
   )*   " )"   6* 7  1@4    9  1@  7 
"0
 4 " " (   " )9       O1@ I  )*
*  "  7 " 9   7  " .  "  1 " 1@0     )*
   1  K1  17 .   1@I 4 9   8 9 ; 9 
9 1 0 =  1    4 7  1@  7"      7   4  4 9  %
  .  0 Q"  (  (   =+(1  7     
+()*  7 " 9   9  " 7 "   (7 )1    +()* * 9 
" "( 1  1@ " 1 70 &" 9   I  "  74 = 9   
;( 7 (    =+(1  74  " 9    "   F" 7  "
(0 =    "  18      7 " 1 7 9  70

using System;

namespace CSharpSchool
{
class Test
{
static void Main()
{
GarbageCollection garCol = new GarbageCollection();
garCol.DoSomething();
garCol.Dispose();
}
}

class GarbageCollection : IDisposable


{
public void DoSomething()
{
Console.WriteLine("Performing usual tasks...");
}

public void Dispose()


{
GC.SuppressFinalize(this);

,





   



Console.WriteLine("Disposing object...");
Console.WriteLine("Freeing resources captured by this object...");
}

~GarbageCollection()
{
Console.WriteLine("Destructing object...");
Console.WriteLine("Freeing resources captured by this object...");
}
}

=  1  ;( 9       K1 9 (   =+(1
 7      +()* 0 !94  "    7  K1   
9  7."(  "  1  1@4 1    +()* 0   " 7  
      I E )* 0 !  9   "(( )*  7 
0K    +()* 0

public void Dispose()
{
GC.SuppressFinalize(this);
Console.WriteLine("Disposing object...");
Console.WriteLine("Freeing resources captured by this object...");
}


 0K   1 "     K1 0 =7 9 (  "  1@  
K0"(( )* 4   )*  ) "* 7  "  1@ 9 I 1 0 =7 9
;"  1  (4 9 9   79  "("

Performing usual tasks...
Disposing object...
Freeing resources captured by this object...
Press any key to continue

"4 7 9   "     +()*   " E )* 0

static void Main()
{
GarbageCollection garCol = new GarbageCollection();
garCol.DoSomething();
// garCol.Dispose();
}







   




 "  9"   +" )  )* * 9  1@     7 0

!9  "(" 9" 1 8 

Performing usual tasks...
Destructing object...
Freeing resources captured by this object...
Press any key to continue

4   & 0 5 $

    "   )*   "    (7   4 74  
   "      "  "  "     " .  " 8
7  4 1  98   0

*' ,  

 :; $
 0K  (      )* 9  7  K1    
" 90 =  "" 1       7  K1    0! "       9
   K1  ( @" 7 7   1@  0 "4 "  "   9 
 "1 7 1@  " (  " .7  )004     *   " 9   
 1 .   0

 
   
 74 9      (.   )   1"  1 (*  "  (0 $  
7     0 !  )    *  7      4 8 

using System;

namespace CSharpSchool
{
class Test
{
static void Main()
{
Outer.Inner inner = new Outer.Inner();
inner.InnerFun();
}
}







   



class Outer
{
private static string name="Faraz";

public Outer()
{
Console.WriteLine("Constructor of Outer called...");
}

public class Inner


{
public Inner()
{
Console.WriteLine("Constructor of Inner called...");
}

public void InnerFun()


{
Console.WriteLine("InnerFun() called...");
Console.WriteLine("Name in Outer is {0}", name);
}
}
}

4 9   7      = 4       (.   O"0   O" 
   =     ."   "0 $  (.      1 8  ("1 
  4    1 8 9    7 ( 4 ("14 (4   4    O
(4 9       1   -0 %8   14  7"  7
7    ( 4 9         1 7     " 
    0 =   7        =     E )*  7   4 9
8   ("1  " (0 =   9.       9      
9 7           0     9 9     =    "
E )*  

static void Main()
{
Outer.Inner inner = new Outer.Inner();
inner.InnerFun();
}

'





   



&  (  (  1"          )( 4   4 (4 ("1*
 1 7     0 $        = " )*  7  =  4
9    (  1 ) * 7     )O"* 0

public void InnerFun()
{
Console.WriteLine("InnerFun() called...");
Console.WriteLine("Name in Outer is {0}", name);
}


$ 9 (   "  1  (4 9   79  "("

Constructor of Inner called...
InnerFun() called...
Name in Outer is Faraz
Press any key to continue


   !" (
      $(
   
!" 

         9 7       4   (   9
     F"   7     0
 4 7     7         
      7     ("14    9"   1 1   "  1
)(@*0

6





   


./  
  %  0 

 &

 9 9 ;( 1     70 $ 9 ;(   1  1 4 1
4  7   9   (   0 % 9 9  9      7  7
7  1 "       (0

/  
  
&1   1 ( 7    ( 0 &1         (
  1 0  1    (    "   7  1
      (  7       "1.0 &1    1
  8 9  1 890 & 1  7 " 1 8 9  1 890
  1    (4    1   0  " 1 "1.    " 
7"  0     9  1   I 1 0 &      1  "
(    1    1 4    " 1    1 0

&      1    (     1        7 
1 0 $    7  7  ( 7 1      (    1@ 7  
      1 0 % "   1  9 9   ((   
 ( )1* 0

abstract class TaxCalculator
{
protected double itemPrice;
protected double tax;

public abstract double CalculateTax();

public double Tax


{
get { return tax; }
}

public double ItemPrice


{
get { return itemPrice; }
}
}

-





   




 ;"     9 7    (( ;0 =     1 
" ;)* 9 "  ; ((          7 ;0  " ;)*
   1     "1.  (   9  7 ((   ;  
0       9 ("1    (( "    9 (  70 =7 9  
    1    E )* 

static void Main()
{
TaxCalculator taxCalc = new TaxCalculator();
}


 ( 9 (

Cannot create an instance of the abstract class or interface
'CSharpSchool.TaxCalculator'

=        7  ;" 4 9   "1. 0 % " 9     7 
1 ;"      ;"0

class SalesTaxCalculator : TaxCalculator
{
public SalesTaxCalculator(double itemPrice)
{
this.itemPrice = itemPrice;
}

public override double CalculateTax()


{
tax = 0.3 * itemPrice;
return itemPrice + tax;
}
}


  ;"     ;"      " ;)* 0 = (( ',\
;   ( 7   ) 1 J*   "   9 ( 7  0   ;"  
7    "  8    (0 =7 9  I (   (  7 
" ;)*    ;"

class SalesTaxCalculator : TaxCalculator
{
public SalesTaxCalculator(double itemPrice)

/





   



{
this.itemPrice = itemPrice;
}

/* public override double CalculateTax()


{
tax = 0.3 * itemPrice;
return itemPrice + tax;
}*/
}


$ 9   (  

'CSharpSchool.SalesTaxCalculator' does not implement inherited abstract member
'CSharpSchool.TaxCalculator.CalculateTax()'

!94 " .     " ;)*    ;"0   9     
" ;)*  7 ;"    ;" 4 9         E )*
0

class Test
{
static void Main()
{
SalesTaxCalculator salesTaxCalc = new SalesTaxCalculator(225);
double newPrice = salesTaxCalc.CalculateTax();
Console.WriteLine("The item price has changed because of sales tax from {0} $ to {1} $",
salesTaxCalc.ItemPrice, newPrice);
Console.WriteLine("Tax applied = {0} $", salesTaxCalc.Tax);
}
}

4 9        ;"  @" 8  "      10 
"(" 7  1  ( 9 1


The item price has changed because of sales tax from 225 $ to 292.5 $
Tax applied = 67.5 $
Press any key to continue

$   "  1  ( ) ;"* 7      1@ 7    
) ;"*  " E )* 0

3





   




static void Main()
{
TaxCalculator taxCalc = new SalesTaxCalculator(225);
double newPrice = taxCalc.CalculateTax();
Console.WriteLine("The item price has changed because of sales tax from {0} $ to {1} $",
taxCalc.ItemPrice, newPrice);
Console.WriteLine("Tax applied = {0} $", taxCalc.Tax);
}


$           9 9  7  1 ;" 4      ( 
 7  7  1 0
       )$""* 7  1
;" 0

class WarSurchargeCalculator : TaxCalculator
{
public WarSurchargeCalculator(double itemPrice)
{
this.itemPrice = itemPrice;
}

public override double CalculateTax()


{
tax = 0.5 * itemPrice;
return itemPrice + tax;
}
}


 $""  1 "    E )* 0

  0 
= 7   ( 8  7 (  4 "  7   (7  )  7   "* 
" 1 79 1  "1.(0
&  7   "    7 890 = 74 8 1 4   1   0 &
 7      " 7  4 ((    ;0 &  7   ( 9 1 
 ("1   1 1 7"0

&  7  (  1  0 &  (     7 " (   1 7  
1 7   70  (    74   "    ;   " 7   0 &
  "  9     (    ("  70

C





   



&   (       74    .   9 "        0
&  7 7      70 $    7  7   7 (     (  
   (     70 =       4  (7;   7  7 9 "(( I=I
8 =+(14 =14 = 14 = "4 0

% " 7    7  =$ 9 

interface IWindow
{
Point Position
{
get; set;
}

string Title
{
get; set;
}

void Draw();
void Minimize();
}


  7 1  7   9 ( =$ 90   7    9 (( 9     18 7
     7  $ 90 =       " 7 9   +9)*    E )*
 9 90 !   7  1   9   ( "0 !94  
  9  (  ) *   7 " (   1 7  10  ((
  7 (  4 9   " (   7    ( 

struct Point
{
public int x;
public int y;

public Point(int x, int y)


{
this.x = x;
this.y = y;
}
}

5





   



=  (   "      7   1 (   (   (7 9 "
1 79 1   (   0  (  7  (7     (  
   9     74 1"   (  )(   1 7*   1 7 
 70

!9  " 7    "$ 9   (  " =$ 9  70

class RectangularWindow : IWindow
{
string title;
Point position;

public RectangularWindow(string title, Point position)


{
this.title = title;
this.position = position;
}

public Point Position


{
get { return position; }
set { position = value; }
}
public string Title
{
get { return title; }
set { title = value; }
}
public void Draw()
{
Console.WriteLine("Drawing Rectangular Window");
}
public void Minimize()
{
Console.WriteLine("Minimizing Rectangular Window");
}
}


  "$ 9  (   =$ 9  7 "    (0

class RectangularWindow : IWindow

,





   



   "$ 9  (    =$ 9  7        1 4 
(   1 7   1 7  =$ 9  70 =    9 (  7    ( 0
 ((     (7   =$ 9  7  (         
( 7 ( 0  9 4 +9)*   E )*4  (   (   ( 0

!  9   (   1   "$ 9    ("14    
("1   =$ 9  70

=7 9  I 8  1  ("14 8

void Draw()
{
Console.WriteLine("Drawing Rectangular Window");
}

$ 9   (. 



'CSharpSchool.RectangularWindow' does not implement interface member
'CSharpSchool.IWindow.Draw()'.
'CSharpSchool.RectangularWindow.Draw()' is either static, not public, or has
the wrong return type.

 (  F" "((     "  (1   7  0 = 74  9  4
  1 7   7  1   ("1 1 7"   9     1   7
   1 "  ((4   9 "    1  ("1 9 (  
  70

&        89 9     1  7   7 )=$ 9*  
(    ) "$ 9*4 8 9 "      "  ((0 =7 " 9  
17  14 " 9   (  

I(0 "$ 90+9)*I  "1  7"    0

  7  ((     89    9   "     7"
(  4 1" (  " 9 (7 (  7  10

(
 1 $  0
&   (       70 = "  4     (   (  7  
1 7  7  (    70 "(( 9   9  7 =%1   =4 8 


interface ILoggable







   



{
void Log(string filename);
}

interface IFile
{
string ReadLine();
void Write(string s);
}


 =%1  7        %) * 9       (7 7 9
  7 =    9  % )*   $) * 0   % )*     7
 7     $) * 9  "((     70 % " 7    )E* 9
(    70

class MyFile : ILoggable, IFile
{
private string filename;

public MyFile(string filename)


{
this.filename = filename;
}

public void Log(string filename)


{
Console.WriteLine("Logging activities in file: {0}", filename);
}

public string ReadLine()


{
return "A line from MyFile";
}

public void Write(string s)


{
Console.WriteLine("Writing `{0}' in the file", s);
}
}


E (  1  =%1    =  7   "   I4I  (   7
 7







   




class MyFile : ILoggable, IFile


     (  7   (7   9 (   7 )=%1  
=*0 E       "  (   7  70  % )*   $)* 
(   7 9   "((    "0  %)*      7  ( 
 (7 0         E )*   (  

class Test
{
static void Main()
{
MyFile aFile = new MyFile("myfile.txt");
aFile.Log("c:\\csharp.txt");
aFile.Write("My name is Faraz");
Console.WriteLine(aFile.ReadLine());
}
}

4 9        7 E     0 $   77   7  
E "   1@0  ( "(" 7  ( 

Logging activities in file: c:\csharp.txt
Writing `My name is Faraz' in the file: myfile.txt
A line from MyFile: myfile.txt
Press any key to continue

2(   ( 4  " 1   7" 1" (   "(  74 1" 9 7   7
  =%1 9 $) *   %) *H   E 9"  1 (  
9  7 )=%1   =*   1     $) * 9   "0

interface ILoggable
{
void Write(string filename);
}

interface IFile
{
string ReadLine();
void Write(string s);
}

'





   



2(
 (
  0 $ 
=7    (        7     9 7     9   "4
 9  (  ;( (  7  ("  1 (7;    9   7 
 7    0 (0     7  1  9 9   9  7 )=%1   =*
  1    $) *  9    "0 %I 9   "  E  
 (  ;( (  7  $)* 0


class MyFile : ILoggable, IFile
{
private string filename;

public MyFile(string filename)


{
this.filename = filename;
}

void ILoggable.Write(string filename)


{
Console.WriteLine("Logging activities in file: {0}", filename);
}

public string ReadLine()


{
return "A line from MyFile: " + filename;
}

public void Write(string s)


{
Console.WriteLine("Writing `{0}' in the file: {1}", s, filename);
}
}

 9   7   $)*  7 =%1 ;( 1 (7;   9   7 

void ILoggable.Write(string filename)


!9 7  (4  9 $)*    "1    7  0 !94 7 9 9 "
E )*  

static void Main()
{

6





   



MyFile aFile = new MyFile("myfile.txt");
aFile.Write("c:\\csharp.txt");
aFile.Write("My name is Faraz");
Console.WriteLine(aFile.ReadLine());
}


9 9"   79  "("

Writing `c:\csharp.txt' in the file: myfile.txt
Writing `My name is Faraz' in the file: myfile.txt
A line from MyFile: myfile.txt
Press any key to continue

!   1     $)* 4  (  )=0$) **  ;"0   
=%10$)* 4 9    (.  1@   7  7  =%1  70

ILoggable logger = aFile;
log.Write("c:\\csharp.txt");


  =%1   (  ( 7 E ) E (  =%1*4  1@ 7 ( E )*
 1 (    =%1 7  )*0  7 E )*  9"  1

static void Main()
{
MyFile aFile = new MyFile("myfile.txt");
aFile.Write("My name is Faraz");
ILoggable logger = aFile;
logger.Write("c:\\csharp.txt");
Console.WriteLine(aFile.ReadLine());
}


&   "(" 9 1

Writing `My name is Faraz' in the file: myfile.txt
Logging activities in file: c:\csharp.txt
A line from MyFile: myfile.txt
Press any key to continue

    0   (   


=   ;(4 9 8 9   1@ )*  .1   =%1  74    9
790 "4    9 9   " 9  (" 1@   .1    7

-





   



(  " .4 9  8 " 7       ( )      (  "  
   - . =     (*0
  (  "  8  ( 7  (" 1@    "   1 "0  ;(4

MyFile aFile = new MyFile("myfile.txt");
Console.WriteLine(aFile is ILoggable);


$ (  "     "("   E   "1.( 7 =%14 9

string s = "faraz";
Console.WriteLine(s is ILoggable);


$ (  0   ( "  " 7  1@   .10 O94    1@  
(7 (0  ;(

MyFile aFile = new MyFile("myfile.txt");
ILoggable logger = aFile as ILoggable;
if(logger == null)
Console.WriteLine("un-successful cast");
else
Console.WriteLine("successful cast");


 "(" 9 1

successful cast

$ 7

Test t = new Test();
ILoggable logger = t as ILoggable;
if(logger == null)
Console.WriteLine("un-successful cast");
else
Console.WriteLine("successful cast");


 "(" 9 1

un-successful cast

 4   9        (71    1 7  7 "    7
7 0

/





   



/  0$      0 
&  7    7      70 "((  =  7   9   7
=1   =$1

interface IWritable
{
void Write(string s);
}

interface IReadable
{
string ReadLine();
}

interface IFile : IWritable, IReadable


{
void Open(string filename);
void Close();
}


  7 =$1      $) *  9  "((     74 9 
 7 =1      % )*  "     7  70   7 =   
9  7 )=$1   =1*       9  )O( ) *   )**  (  
  70 % " 9 7     E  (    7 =0     ( 
 1 7    (  )   *   =  70

class MyFile : IFile
{
private string filename;

public void Open(string filename)


{
this.filename = filename;
Console.WriteLine("Opening file: {0}", filename);
}

public string ReadLine()


{
return "Reading a line from MyFile: " + filename;
}

public void Write(string s)

3





   



{
Console.WriteLine("Writing `{0}' in the file: {1}", s, filename);
}

public void Close()


{
Console.WriteLine("Closing the file: {0}", filename);
}
}


  (   ( (  7    1 (       1 7  0

       E )*  

class Test
{
static void Main()
{
MyFile aFile = new MyFile();
aFile.Open("c:\\csharp.txt");
aFile.Write("My name is Faraz");
Console.WriteLine(aFile.ReadLine());
aFile.Close();
}
}

4 9        7 E     7  0 $   77    
1@ "   7 0

 "(" 7  ( 

Opening file: c:\csharp.txt
Writing `My name is Faraz' in the file: c:\csharp.txt
Reading a line from MyFile: c:\csharp.txt
Closing the file: c:\csharp.txt
Press any key to continue

 "(" 9  " 7        0

C





   


/ ' + 

  %* 1(


 

 &

 9 9 ;( 4        ("  0  7 4 9 9 ;(
"    "   @ 0 $ 9  ;( 9 7  "   0
 9 9         9   (   0 %4 9 9 ;( 77 
  8 &%4 84 R""   + 0  4 9 9  9     (" 
0 $ 9 ;( 1        " (0

/ ' 85  


& 9    4     F"   7   7    (0 = 4    
1@   "  7  (4   7      (0 $          
   ( "  4 9 9 9 ;( "   0

1
 
/ '  
& "      I 7 I0 & "         9    7 
    70 =    1   1 9  (   )9*    7
    )" *0 =7            7   4   
 .    )   ( 7 "   *4 9     .  
 9   ( 7   7 0   9 ( 7 "     

  "  )   9  9     F" "1 7 " *
 #  )   9  9       F" "1 7 " *

  19 9 9  77  8  7  8 80  7"  9   ; 7 77 
  7  0 14  7   7    9  ),*0

5





   



%" 
      ! 

#"

 &" '$ 
 ( ') (
#"

      ! 
         #

      
 "  !! !   

#

 &" '*

(
#"

      !  #"

         ! "" 
        # 

 "  !! !  

#

 &"  '+) ,) +(


# #

     !


     #

  "   " 

# #

',





   




     $
 0
 
 ' 
  9    "       8 

int [] intArray = new int[5];


 1    9"    )*        ) &* 7 (  4   9 -  0 $
     7   8 

intArray[0] = 45; // set the first element to 45
intArray[2] = 21; // set the third element to 21
intArray[4] = 9; // set the fifth and last element to 9


=     "          1  ("4     " 8(  
1 7  7  "       9  I "       7 I0
"(( 9 9    9     "  9  9   ' " 0 $     
  79

int [,] myTable = new int[2,3];


&    7    ".    7" "U       7   1 
9" 1   9 0 $   "   "    7 (   7 (0

foreach(int intVal in myTable)
{
Console.WriteLine(intVal);
}


$   (   ;"4  9 (  ; ) ; '* 0

0
0
0
0
0
0

!94  "    " 7    "   7  0     " 7  7   7
 7 9  '4 9  9  79  

myTable[0,0] = 32;

'





   




=   9 9     " 7    7  

myTable[0,1] = 2;
myTable[0,2] = 12;
myTable[1,0] = 18;
myTable[1,1] = 74;
myTable[1,2] = -13;


!94 9  "  "( 7  7 (      

for(int row=0; row<myTable.GetLength(0); row++)
{
for(int col=0; col<myTable.GetLength(1); col++)
{
Console.WriteLine("Element at {0},{1} is {2}", row, col, myTable[row,col]);
}
}

4 9   " 9 7 (   "  7  9    7  0 $   " 
K% )*  7  0&  ) "    7   0!*  7     7 
("   7  0 !   %  (( 9    "1 7     9
   4 004 /0  "(" 7  1  ( 9 1

Element at 0,0 is 3
Element at 0,1 is 2
Element at 0,2 is 12
Element at 1,0 is 18
Element at 1,1 is 74
Element at 1,2 is -13

    </ ' 


& @      9    7  9    0  ;( 9  9    1
9 ' 9 9    7  7 9  '4    9  -     9  0 $     
@  8 

int [][] myTable = new int[3][];
myTable[0] = new int[3];
myTable[1] = new int[5];
myTable[2] = new int[2];

'





   



 9  7   8 

myTable[0][0] = 3;
myTable[0][1] = -2;
myTable[0][2] = 16;

myTable[1][0] = 1;
myTable[1][1] = 9;
myTable[1][2] = 5;
myTable[1][3] = 6;
myTable[1][4] = 98;

myTable[2][0] = 19;
myTable[2][1] = 6;


!94 9 9 9 9  "  7 (      7  

foreach(int []row in myTable)
{
foreach(int col in row)
{
Console.WriteLine(col);
}
Console.WriteLine();
}


  1    (    "  10 $ (8 "(  9 )9     *   
 "  9 9 (    7  " 0  "(" 7  1   9 1

3
-2
16

1
9
5
6
98

19
6

''





   


Press any key to continue



=   94 9  "  .   

int [,,] myTable = new int[3,2,4];

myTable[0,0,0] = 3;
myTable[1,1,1] = 6;


O  @  7

int [][][] myTable = new int[2][][];
myTable[0] = new int[2][];
myTable[0][0] = new int[3];
myTable[0][1] = new int[4];

myTable[1] = new int[3][];


myTable[1][0] = new int[2];
myTable[1][1] = new int[4];
myTable[1][2] = new int[3];

myTable[0][0][0] = 34;
myTable[0][1][1] = 43;
myTable[1][2][2] = 76;

4 9         @ 0 =    7 9 .   0  7 7 
.        90    7  7 9  '4 9    7   9  60 = 
 7 4    9        0 =   4 9     7 
  7        77  "0 &"     @   F"
77"  ( U   1  "7"   (; (10 & 4  8     7" 
"      (     I 7 I0

* $ (  (   


 
 ' 
=  ;( 9 @" 94 9   " "    7      (0 "4 "  
 7    (0  ;(4 "  7    7        7 1@ 7 " 9
0

string []names = new string[4];


Q"       7     7   79  9

'6





   




string []names = new string[4]{"Faraz", "Gates", "Hejlsberg", "Gosling"};




string []names = new string[]{"Faraz", "Gates", "Hejlsberg", "Gosling"};



string []names = {"Faraz", "Gates", "Hejlsberg", "Gosling"};


Q"   (       7   7     

string []names;
names = new string[4]{"Faraz", "Gates", "Hejlsberg", "Gosling"};


Q"     9.      7 )  9   *

string [][]nameLists = {new string[]{"Faraz", "Gates"},
new string[]{"Hejlsberg", "Gosling", "Bjarne"}};


 7   (  (( L    1 ((   

 %     "1 7        7  
 K% ) *    "1 7     ("   7  
 K2((" )*    "(( 1"  7  (7   7  
 K%9" )*    9 1"  7  (7   7  

$0 $(
$   1 "   7 ( 7 F"     90 % "  9  98   9  9  1 "
  1    1  7 (0  4 9   (   = "1  7 9
        4 K ")*4  "   1@ 7 ( = "0  = "
 7      ("1 (( )" *   9 ("1  E !;)*   )*0  " 
((     = "  7 

object Current { get; }


= "   "    7   9  7 1@  (0  E !;)*    

bool MoveNext();

'-





   



=     "     ;   7     "  " 7      
"7"4   7 7     0 $ E !;)*   7  7 4    
  7      9     "  ((    "  E !;)*  1
;" 7  7 0

 4  )*    

void Reset();


     "         0 &7 4 E !;)* 9     
   7      0

!9 9 9 9 9  8     1    "   7 (4 1 (   
= "1   = "  70

using System;
using System.Collections;

namespace CSharpSchool
{
class Test
{
static void Main()
{
MyList list = new MyList();
foreach(string name in list)
{
Console.WriteLine(name);
}
}
}

class MyList : IEnumerable


{
static string []names = {"Faraz", "Gates", "Hejlsberg", "Gosling", "Bjarne"};
public IEnumerator GetEnumerator()
{
return new MyEnumerator();
}

private class MyEnumerator : IEnumerator


{

'/





   



int index = -1;
public object Current
{
get { return names[index]; }
}

public bool MoveNext()


{
if(++index >= names.Length)
return false;
else
return true;
}

public void Reset()


{
index = -1;
}
}
}
}

 9       E% 9     (     E "0 
 E " (  = " 1 (    (  7  ("1 ((  
0   E% (   = "1  7   "   1@ 7 ( E " 
 K ")* 0   E%       7    0  E "
  "  0 = "    1  ;  8( 8 7  "    7 
 0  1  ;    9 .0    E !;)*   4      1
   "  "  74 (    9  I 7     1 0  "  ((
"    ;   7   9  )*    1  ;  .  0

=    9       E%     "  "   7 (4 1" 9
  (  = "1  7   E% 0  "(" 7  1  ( 

Faraz
Gates
Hejlsberg
Gosling
Bjarne
Press any key to continue

'3





   





  
&" 9  8   7  1@ "  4      9 "   7
 0   7    9 7;   " 1 7     7    7  0
 4        1@ 7    (4 9 9   7     7 
   0 &4     (   ("   7            7
  0   ("(4   7     0! 98  %1 )%*   (  
"1 7        7 77  (0    (    0 
(0

 7     7  ( 

 +(
&%        4 1"  9     "1 7
   0
8 &   98   % =  O" )%=O* ( (4 004      
 7    7   0
R"" &   98    =  O" )=O* ( (4 004  7   
  7    7   0

 1     7 8. " (     1     7  80
%     7 8. " ( 9         80 
  1 1 1  8     ;0

& 7  1   (   =  74 9     ((     

  "  (( "   "1 7      )   %  (( 7 
&*
  =   (( "   1 " (    9     
.7  
    (( "   1@   1 "         0
  ( )& 4    ;*  (    7     4  
7  (7  ;0

&     (   = "1  74    1    "   7
(0

$/ ' 
 
 0 0&%     4 1"     7    (0 $  I 
 (7   7   9 "   &% ) 9 "      7 ( *0 
 7  &% 9     "1 7        0 & &% "  
         9  7" "  (0 &  "1 7     
4 &% @"  ( 7     1 8   9    (    "
'C





   



  0   7  &%    "1 7     " (    9  ( 
 "1 7    &%   9"      9 0 & &%  1  "
8 

ArrayList list = new ArrayList();


$   (7    ( 7  &% 1 (     "    "

ArrayList list = new ArrayList(20);


$     &% 9    1 (       "
ArrayList list = new ArrayList(someCollection);


$      &% 1 "   &)* 0  &)*  8  1@ 7 ( 1@ 
 (0

list.Add(45);
list.Add(87);
list.Add(12);


 9    "1   &%0 !94 9   "     &% )* " 
 7 (

static void Main()
{
ArrayList list = new ArrayList();
list.Add(45);
list.Add(87);
list.Add(12);
foreach(int num in list)
{
Console.WriteLine(num);
}
}


9 9 (  "      &% 

45
87
12
Press any key to continue

'5





   




 (
 
 $     *  +  
  *+  #    - &  !" #  
     #
  -   

 &%    (    ; (( )  ; (* 9 9     1
 "   ST (4 @"  "  9  (  )9 9  9  (   ;  
;  *0  79       1   1" "   ;      7 
&%0


static void Main()
{
ArrayList list = new ArrayList();
list.Add(45);
list.Add(87);
list.Add(12);
for(int i=0; i<list.Count; i++)
{
Console.WriteLine(list[i]);
}
}


 "(" 7   9 1      (  ( "0  1   "  (( "  
7   "  "1 7     &%0   &%    (( )" * 7 
(   7 = 0

&  7   (  ((    7  &%   (    79  1

(  E +(
( K    "1 7    &%    0
"  K  ; "1 7     &%0
&)1@* &        7  &%0
 )1@*      7  &%0
 &) *        (7  ; 7  &%0
= ) 4 1@* =   1@   &%   (7  ;0
)*       7  &%
  )1@* "   1 "    9  &%     "((
   0
( )* (    7  &%    "((   (0  
        (7     1 (    7 9  ; 7
  ( " 0
= ;O7)1@* "    1  ; 7  7 "  7  1@   &%0 =7
6,





   



 1@   7"    &%4  "  .0
%= ;O7)1@* "    1  ; 7   "  7  1@   &%0
&)* "    7 ( 1@         7  &%0
 )*   (   " "1 7     &%0

$* 9
 
 0 08    8  7   (        0 & 8
98   ( ( 7 % =  O" )%=O*4 9            8 9 1 
7   1   7 0 8   R""     ""  ("     
 (   1 9   790    7      8     I"I 9
     7  8    I(I0 =7       1"    7  ( 7  84
     I8I ( 0  0 08  (   7"   7  8 
 0!    0  8   1             9 " 7  &%0

Stack stack = new Stack();


 1  )7"*  " 9    9 ( 80  79   "  9   
8 9  "((   (

Stack stack = new Stack(12);


$  79   " 9    8 9  "(( 

Stack stack = new Stack(myCollection);


!94 9  ("      8 "   ")* 4 8 

stack.Push(2);
stack.Push(4);
stack.Push(6);


=    4 9      7  8 "   ()* 0 & ( ( 
(" '      8    ((  77   1    (  19

using System;
using System.Collections;

namespace CSharpSchool
{
class Test
{

6





   



static void Main()
{
Stack stack = new Stack();
stack.Push(2);
stack.Push(4);
stack.Push(6);

while(stack.Count != 0)
{
Console.WriteLine(stack.Pop());
}
}
}
}


!  9   "  9)* (    "    7  80 O     1 
  7  8    ()* (    "       ( 7 84 1"    
(     "  " 9  9  ()* ( 0  "(" 7  1  ( 9 1

6
4
2
Press any key to continue

     8       7  &% ;( 7  8)* 0 
8)*  "   (   7  8 9"    0  79  (   
" 7  8)* ( 0

static void Main()
{
Stack stack = new Stack();
stack.Push(2);
stack.Push(4);
stack.Push(6);

Console.WriteLine("The total number of elements on the stack before Peek() = {0}", stack.Count);
Console.WriteLine("The top element of stack is {0}",
stack.Peek());
Console.WriteLine("The total number of elements on the stack after Peek() = {0}", stack.Count);
}

6





   



 1  ( ("       8    (8   (     80 
( (   "1 7     8 17   7  8)* ( 0  " 7  (


The total number of elements on the stack before Peek() = 3
The top element of stack is 6
The total number of elements on the stack after Peek() = 3
Press any key to continue

 "(" 7  ( 9  8)*   77  "1 7     8    
   (  4     ()* ( 0

$F
 
& R"" 98   ( ( 7  =  O" )=O*4 9     7       F""
9 1  7    7 0  I F""I           F""4     7  
7  F""   I+F""I0 %8  84     8 ( 4 9       1"
   7  7  7  F""0

 0 0R""  (   7"   7 F""   0!    0  R""I
 "     7  &%    80

// an empty queue
Queue queue = new Queue();

// a queue with initial capacity 16


Queue queue = new Queue(16);

// a queue containing elements from myCollection


Queue queue = new Queue(myCollection);


 79  (    " 7 R""  0

static void Main()
{
Queue queue = new Queue();
queue.Enqueue(2);
queue.Enqueue(4);
queue.Enqueue(6);

while(queue.Count != 0)
{

6'





   



Console.WriteLine(queue.Dequeue());
}
}


 (  F""       R""    F""  "   9 (0  "(" 7 
( 

2
4
6
Press any key to continue

 "(" 9   F""        9  0    7  R"" 
    7  &%   8 0

4   
+    8  7       8. " ( 7 0  "    
 7 1  80 &  8     " F"      1     8 9  
0         "   8  O;7 +  9  9 )8*  
(      ) "*0  9   ( 7 +    0  (
 
1    %0

$3 $ 

 

1    8. " (0   ) "*   1  " F"  7 1  80 &
1   8    "   1@ (0 E      "   8   14 1"
"  "       80
9 4 17     7  84 1 "     F")*
  K
)*      7  1@  " 

 F")* 8 7    F"    7" 7  F"0
 K
)* "      7     7  0
  " "  1 K
)*     1" 19  E N"    E;N"
7  =  (0

  3 $ 

      7    (      %1     "4    
 "1 7 "   8  1    0      "  1 
    10  ( 

Hashtable ht = new Hashtable();

66





   




$   7"  "   "0 & 1   1  " 1 (      (

Hashtable ht = new Hashtable(20);



1         " 9 9 "     1 9 
    0

/   3 $ 

O  "       1 1@4  "      "   &)* 

ht.Add("st01", "Faraz");
ht.Add("sci01", "Newton");
ht.Add("sci02", "Einstein");

8 5  0  $3 $ 




 9          1   9  80 &  ("   1  
"   8

Console.WriteLine("Size of Hashtable is {0}", ht.Count);
Console.WriteLine("Element with key = st01 is {0}", ht["st01"]);
Console.WriteLine("Size of Hashtable is {0}", ht.Count);

 9   "   ; )ST (*     " 7  10  9 7    
     7  1 1" @" "   1@ 9  (7 80 74   17
  7    (  9  )  '*0  "(" 7   1  

Size of Hashtable is 3
Element with key = st01 is Faraz
Size of Hashtable is 3
Press any key to continue

85( 
  
   7  1  1   1 "    )*  9 8  8 7    1
    " 0

static void Main()
{
Hashtable ht = new Hashtable(20);
ht.Add("st01", "Faraz");

6-





   



ht.Add("sci01", "Newton");
ht.Add("sci02", "Einstein");

Console.WriteLine("Size of Hashtable is {0}", ht.Count);


Console.WriteLine("Removing element with key = st01");
ht.Remove("st01");
Console.WriteLine("Size of Hashtable is {0}", ht.Count);
}


 "(" 7  ( 

Size of Hashtable is 3
Removing element with key = st01
Size of Hashtable is 2
Press any key to continue

,  $

 09' 5
 
  7   8   "   1  1   "   G   N" ((4 9
"  =       8   " ( 0  79  (  " 
 8   "   (  4 "   7 (0

static void Main()
{
Hashtable ht = new Hashtable(20);
ht.Add("st01", "Faraz");
ht.Add("sci01", "Newton");
ht.Add("sci02", "Einstein");

Console.WriteLine("Printing Keys...");
foreach(string key in ht.Keys)
{
Console.WriteLine(key);
}

Console.WriteLine("\nPrinting Values...");
foreach(string Value in ht.Values)
{
Console.WriteLine(Value);
}
}

6/





   



 "(" 7  ( 9 1

Printing Keys...
st01
sci02
sci01

Printing Values...
Faraz
Einstein
Newton
Press any key to continue

$90  $2 0( 


  $ $ 

Q"  "    G)*      N")*   7  " 9  ("  9 
(7 8   " ;   1  0    "  1 "0

static void Main()
{
Hashtable ht = new Hashtable(20);
ht.Add("st01", "Faraz");
ht.Add("sci01", "Newton");
ht.Add("sci02", "Einstein");

Console.WriteLine(ht.ContainsKey("sci01"));
Console.WriteLine(ht.ContainsKey("st00"));
Console.WriteLine(ht.ContainsValue("Einstein"));
}


 "(" 

True
False
True

=   9     F" ;     )1*  0

$*  
 
       
14  77  1           80
O  7     7 "   %   "        "      ;4
@" 8 "  9  0 =   7 %4 7 " 9   " " 9    8  4  

63





   



     1 
14 "    8 "  "  (  
=(1  70

 =(1  7         ( )1@ 1@*0   8  1@ (
"    "     (   9  "(( 1@  F" 4      
"  1@0

 & " " 7 ,     1@  F"   "(( 1@0
 & " "        1@     "(( 1@
 & " "        1@     "(( 1@0

       (   ( (   (  7   7      1 "
 8   % 0

 % (    "  (  1 
1    (      " 
 "0

SortedList sl = new SortedList();


 79  1   "7" ((    7  % 

(  E +(
"  K  "1 7     %   0
G "   = 7   8   %0
N" "   = 7   "   %0
&)1@ 84 1@ "* &    )8. " (*   %0
KG)   ;* "   8   (7  ;0
K= ;)   ;* "   "   (7  ;0
= ;O7G)1@ 8* "    1  ; 7  (7 80
= ;O7N")1@ "* "    1  ; 7  (7 "0
 )1@ 8*      9  (7 8 7  %0
 &) *        (7  ; 7  %0
)*       7  %0
  G)1@ 8* "   1 "    9  %      
9  "(( 80
  N")1@ "* "   1 "    9  %      
9  "(( "0

6C





   



 79  (    " 7  %0

static void Main()
{
SortedList sl = new SortedList();
sl.Add(32, "Java");
sl.Add(21, "C#");
sl.Add(7, "VB.Net");
sl.Add(49, "C++");

Console.WriteLine("The items in the sorted order are...");


Console.WriteLine("\t Key \t\t Value");
Console.WriteLine("\t === \t\t =====");
for(int i=0; i<sl.Count; i++)
{
Console.WriteLine("\t {0} \t\t {1}", sl.GetKey(i), sl.GetByIndex(i));
}
}


 (    7 77  (   " )   7* "    80   7
(  "     8   "      % )*0       4   
          9 9     1  KG)*   K= ;)* 4
9     7 0  "(" 7  ( 9 1

The items in the sorted order are...
Key Value
== =====
7 VB.Net
21 C#
32 Java
49 C++
Press any key to continue

* 3
 
 ; (  I   1"         (   "0 = 4      1"
   (   (0  (   (   (   0  0  1@ 7   
 )  *  "1 1 "0  "1       7  1@   1   1
  ( 0     9 9 9   2(()*    4   I     
  1"    "   9   1@    "((  (  7    1@0 
"1  7     0! 7  0 ;0 " 0  1@ 7   
"14  4    1   1  ( 0
 4 7 "   &(( )*   

65





   



 "  1@4  9   9 1 ((   )     7*    1@0 %I 9
"  9    1  0

$ 
    
$   1 "        " 7     0 $      7  ((
)8 % *    )8 F")**  ( "  0
4 9 9 1  7  
((    7           "  0


(  E +(
%  K  "1 7     1@   0
( )  * (     7    9  "((      "  
    ( 7  =(1  70
()  4   *        (  9 "((     ( 7
 =(1  70
F")  * "  " 7  "((    ;      4  " 
70
 )  * "   9         ) * 7     "((
  0
= )   ;4   * "   9   1     "((      (7  ; 7
  0
()  *    "   9      ( 7  "((  0
=  )  *    "   I 7    "((  0
$)  * "  " 7     9  "((   0
 $)  * "  " 7      9  "((   0
= ;O7)  * "    1  ; 7  7 "  7  "((    
= ;O7) * "((  0           
 10
%= ;O7)  * "    1  ; 7   "  7  "((    
%= ;O7) * "((  0           
 10
()4 * "   9   1 (   "  7  7  9 
() 4  *    ) 7   9     *0
()( ST* = 7  "1  )    * 9   1    
 (7   4  (  "1         
"  0
"1 )  *    "1  7      7   ; (     
"1 )  4   '*   7   70 =      74    
"1    7   ;    9     7 ' 0
&)* "    7  7   0
2(()* "   ( 7     "((0
-,





   



%9)* "   ( 7     90
)* "   9   1     "  7   7 (7 
7  1        7    0
)* "   9   1     "  7   7 (7 
7  1   7    0
 )* "   9   1     "  7   7 (7 
7    7    0

=  79  ( 9      " 7  7  1   7    0 
(  F" 7.;(       "       "0

using System;

namespace CSharpSchool
{
class Test
{
static void Main()
{
string s1 = "faraz";
string s2 = "fraz";
string s3 = "Faraz";
string s4 = "C# is a great programming language!";
string s5 = " This is the target text ";

Console.WriteLine("Length of {0} is {1}", s1, s1.Length);


Console.WriteLine("Comparision result for {0} with {1} is {2}", s1, s2, s1.CompareTo(s2));
Console.WriteLine("Equality checking of {0} with {1} returns {2}", s1, s3, s1.Equals(s3));
Console.WriteLine("Equality checking of {0} with lowercase {1} ({2}) returns {3}",
s1, s3, s3.ToLower(), s1.Equals(s3.ToLower()));
Console.WriteLine("The index of a in {0} is {1}", s3, s3.IndexOf('a'));
Console.WriteLine("The last index of a in {0} is {1}", s3, s3.LastIndexOf('a'));
Console.WriteLine("The individual words of `{0}' are", s4);

string []words = s4.Split(' ');


foreach(string word in words)
{
Console.WriteLine("\t {0}", word);
}

Console.WriteLine("\nThe substring of \n\t`{0}' \nfrom index 3 of length 10 is \n\t`{1}'",


s4, s4.Substring(3, 10));

-





   



Console.WriteLine("\nThe string \n\t`{0}'\nafter trimming is \n\t`{1}'", s5, s5.Trim());
}
}
}


 "(" 7  ( 9   ( " "    1  7  10

Length of faraz is 5
Comparison result for faraz with fraz is -1
Equality checking of faraz with Faraz returns False
Equality checking of faraz with lowercase Faraz (faraz) returns True
The index of a in Faraz is 1
The last index of a in Faraz is 3
The individual words of `C# is a great programming language!' are
C#
is
a
great
programming
language!

The substring of
`C# is a great programming language!'
from index 3 of length 10 is
`is a great'

The string
` This is the target text '
after trimming is
`This is the target text'
Press any key to continue

$* 7
 
 
 0 ;0 "       0   9  77    
"1U  4      7  1@  1 7 1  ( 0 2 8     4 "
" 7    " 7   "      1@0

string s = "This is held by string";
StringBuilder sb = new StringBuilder("This is held by StringBuilder");

-





   



 "  9   &%        9   9 "  
 7         0
 4  ( 7   "  1 77  7  % 0
 7    ((    7   "      79  1

(  E +(
%  K  "1 7     " 1@   0
( K  "  ( 7   " 1@0
&(( )* &((     (  7  (7 1@     7 
 "   0     "1 7   70
= )* =     (  7  (7 1@   (7  ; 7
  " 1@0
()4 * (  "  7  7 "((  )  * 9 
() 4  *   "((  )  *    " 1@0
 )  4    *     7   ; (  7 (7    
"   " 1@0
F") "* 8  "((  " 1@ 9       "  " 7
1   U 94  "  70

 79  (    " 7  7  

using System;
using System.Text;

namespace CSharpSchool
{
class Test
{
static void Main()
{
StringBuilder sb = new StringBuilder("The text");
string s = " is complete";
Console.WriteLine("Length of StringBuilder `{0}' is {1}", sb, sb.Length);
Console.WriteLine("Capacity of StringBuilder `{0}' is {1}", sb, sb.Capacity);
Console.WriteLine("\nStringBuilder before appending is `{0}'", sb);
Console.WriteLine("StringBuilder after appending `{0}' is `{1}'", s, sb.Append(s));
Console.WriteLine("\nStringBuilder after inserting `now' is `{0}'", sb.Insert(11, "
now"));
Console.WriteLine("\nStringBuilder after removing 'is ' is `{0}'", sb.Remove(8, 3));
Console.WriteLine("\nStringBuilder after replacing all `e' with `x' is {0}",
sb.Replace('e', 'x'));
}
}

-'





   



}


&   "(" 7  ( 

Length of StringBuilder `The text' is 8
Capacity of StringBuilder `The text' is 16
StringBuilder before appending is `The text'
StringBuilder after appending ` is complete' is `The text is complete'
StringBuilder after inserting `now' is `The text is now complete'
StringBuilder after removing 'is ' is `The text now complete'
StringBuilder after replacing all `e' with `x' is Thx txxt now complxtx
Press any key to continue

!    4    1@ 7   "    74    " 1@ 
"1 (   "1   1@0

-6





   


)2( 3


 &

 9 9 ;( ;(       0 $ 9  " 1 8     1 
;(    9  9 77  ;(   "0 %4 9 9 ;( 77  7" (   
   (( 1   (  ;(   0  4 9 9  9  7  " 9 "
;( 0

2(  7  


" (4 ;(           " .   0!  9" 9 " "
79    ("0

$0 2(  


   79  ( 

using System;

namespace CSharpSchool
{
class Test
{
static void Main()
{
double p = Divide(3, 5);
Console.WriteLine(p);
}
static double Divide(double a, double b)
{
double c = a/b;
return c;
}
}
}


 + )*  "   " 7    7  9 "1 (  (0  "(" 7 
( 9 1

0.6

--





   




" 9 7   + )*     E )*  

double p = Divide(3, 0);


 9 1  (    1  (  .1  "10 " 9  ( 
;"4  (" 9 (    ' 1  9   (10 &  "4  ( 9 J
O  9   9    ;( 8    (   7    "  "   
 

static double Divide(double a, double b)
{
if(d == 0)
{
return 0;
}
double c = a/b;
return c;
}


    9 1

static void Main()
{
double p = Divide(3, 5);
if(p == 0)
Console.WriteLine("Error in input");
else
Console.WriteLine(p);
}

 9 "  " II         ("0 "  (1     7 1  " 7
   8 ),   1 6*           7" 9  "  "  
     "4 00


static void Main()
{
double p = Divide(0, 3);
if(p == 0)
Console.WriteLine("Error in input");
else

-/





   



Console.WriteLine(p);
}


=    ( 9 (         ("4 9     0  9  9
   (1H

2(    


(   98   (1    (  "   7 7 I;( I0  
7    9  ;(    7 " ;(   0 9   (  (  1" ;( 
  ;(          0!

 & ;(   0!  1@0  0;(    1  7  ;(   0!0
&      9  ;(    7  " ;(    "   ;"
"   9 89  0  9 ;(  1 "   9    
"   000 180
     9  ;( 9 9 9      ("    180    
(    ;( 0       9 ;(  (    18 @"
7   180       ;( 0 $  7  9 ("  7
;( 9 9       18 1       7 ;( 7  
89 E"(  18  1 7  7     18 9   18 9  
("  7 ;( 0
    " 9 1 ;" 7    000 18  (   7  184
( @" 7    000 180    "   9 1 ;" 9 
;( "  0
 $  ;(   "   ;" 7       184      
  18        7 ;"   7   (    7 
180
   ;(   (   0!     1@4  79     0 
   7 " 9   18     1  ;( 4  9 "    7 
"1.I ;( 0 &(      7  "1.I ;(  ;( 7  ( 
 ;( 9 "  (  0
  7  18  ( 0 ;(    F"  1  7   0004
0000007   0007  180
 =7 "     ;( 4  "      ) % " "   %* 9
   " 174 "  " (   0


 2 (
 
        $ #  !"#   
  $ 3    $  !"&    $ #  !"4    
  !"     $ #  #    

!"   5     3-    !"
 
     $ #  !" 

-3





   





 
         

3
2(    $ ' $0

'
9 
A 0 $ ' $
9
& (   7  " 7  000 18    190

static void Main()
{
string s = null;
try
{
Console.WriteLine("In try block... before calling s.ToLower()");
Console.WriteLine(s.ToLower());
Console.WriteLine("In try block... after calling s.ToLower()");
}
catch(NullReferenceException e)
{
Console.WriteLine("In catch block...");
Console.WriteLine("NullReferenceException Caught");
}
Console.WriteLine("After try...catch block");
}


   II  E )*     " "0 $ 9 (    %9)*    "
7     0$% )* 4  % ) % " " * 9  
!"7 ;( 0   9         %9)*     184  " 
9  7   18 9    ;(  4 7    7" 4  ;" 9 @"(  
 180   ; 7   18  (   "  0 = (  7  4  7  )II
 " * 7 "  ;(    )!"7 ;(  " *0 $  1 
(  ;"4  "(" 

In try block... before calling s.ToLower()
In catch block...
NullReferenceException Caught
After try...catch block
Press any key to continue

%8 7"   "(" 7  (   (  9  " 0    0 %9)*  
!"7 ;( 0 &  "4  ;" 7     ( 7   18      
( ;"   7    180 1   !"7 ;(   9 9

-C





   



(    1 7   "   " 7 0 %     1   1    
1@   7  II

string s = "Faraz";
try
{
Console.WriteLine("In try block... before calling s.ToLower()");
Console.WriteLine(s.ToLower());
Console.WriteLine("In try block... after calling s.ToLower()");
}
catch(NullReferenceException e)
{
Console.WriteLine("In catch block...");
Console.WriteLine("NullReferenceException Caught");
}
Console.WriteLine("After try...catch block");


   (   "   ;(   1 4  ;" 7 ( 9 "  

In try block... before calling s.ToLower()
Faraz
In try block... after calling s.ToLower()
After try...catch block
Press any key to continue

2( 
 G1 * 9 & (  
!    "    18  I  ;" 1" 7  1  7 !"7 ;( 0
!9     000 184    "  9    7 (4    9 (( 0

static void Main()
{
string s = null;
Console.WriteLine("Before printing lower case string...");
Console.WriteLine(s.ToLower());
Console.WriteLine("After printing lower case string...");
}

-5





   



$ 9 (   ;"  1  (4 9   79  "("

Before printing lower case string...
Unhandled Exception: System.NullReferenceException: Object reference not set
to an instance of an object.
at CSharpSchool.Test.Main() in
c:\documents and settings\administrator\my documents\visual studio
projects\myconsole\class1.cs:line 11
Press any key to continue

  9     !"7 ;( 4 " (    (" 9  " 
)%* (  9  

0 ;( E  1  ;(

0 8  7  " 7 ;"     7 7"   9 "  ;( 0 = "
  9   ;(  " 1  E )*  7         (
( )(0 0E )**0  8   (  "  7    9  ( (
     "1 9     " 7  ;( 0

" 9  I 9  " (   9  ;( "4 9 (     ;(  
 1 " 1 " 0 %I    " ( "  9 9 "  !"7 ;(  
 180 $   (   E   8  7  ;( "   E    8 
(( 7  ;( 0    79  

static void Main()
{
string s = null;
try
{
Console.WriteLine("In try block... before calling s.ToLower()");
Console.WriteLine(s.ToLower());
Console.WriteLine("In try block... after calling s.ToLower()");
}
catch(NullReferenceException e)
{
Console.WriteLine("\nIn catch block...");
Console.WriteLine("NullReferenceException Caught");
Console.WriteLine("\nException Message");
Console.WriteLine("=============");
Console.WriteLine(e.Message);
Console.WriteLine("\nException Stack Trace");

/,





   



Console.WriteLine("==============");
Console.WriteLine(e.StackTrace);
}
Console.WriteLine("\nAfter try...catch block");
}


 77  19       ( "     9   (   ;(    
8  7  ;( ;( 1 "   ;( 7 0  "(" 7  ( 9 1

In try block... before calling s.ToLower()

In catch block...
NullReferenceException Caught

Exception Message
=================
Object reference not set to an instance of an object.

Exception Stack Trace


=================
at CSharpSchool.Test.Main() in c:\documents and settings\administrator\
my documents\visual studio projects\myconsole\class1.cs:line 14

After try...catch block


Press any key to continue

$0

'
9
 (  7  18  @" 7     180     7  18  "  
9 1 ;" 9  ;( "      180 2"4  7  18  "  7
  " F" 9   18  "  1  1" 7  ;( 0  ;(4 
7  18  1 "    74 14 8       (  " (   
 180 %I   7  18  " ( " ;(0

static void Main()
{
string s = "Faraz";
try
{
Console.WriteLine("In try block... before calling s.ToLower()");
Console.WriteLine(s.ToLower());
Console.WriteLine("In try block... after calling s.ToLower()");

/





   



}
catch(NullReferenceException e)
{
Console.WriteLine("\nIn catch block...");
Console.WriteLine("NullReferenceException Caught");
}
finally
{
Console.WriteLine("\nIn finally block...");
}
}


$ 9 ;"  ( 9   79  "("

In try block... before calling s.ToLower()
faraz
In try block... after calling s.ToLower()

In finally block...
Press any key to continue

   ;(  4     7  18  ;" @" 7      180 % "
 ;(  " 1      II  "  E )*

static void Main()
{
string s = null;
...
}


!9  "(" 9 1

In try block... before calling s.ToLower()

In catch block...
NullReferenceException Caught

In finally block...
Press any key to continue

 "(" 9      7  18  9 ;" 7  ;" 7      18
 7 7  ;( "  0

/





   




=  (1  9  0007  18 9"    184 00

static void Main()
{
string s = "Faraz";
try
{
Console.WriteLine("In try block... before calling s.ToLower()");
Console.WriteLine(s.ToLower());
Console.WriteLine("In try block... after calling s.ToLower()");
}
finally
{
Console.WriteLine("\nIn finally block...");
}
}


 "(" 7  ( 9 1

In try block... before calling s.ToLower()
faraz
In try block... after calling s.ToLower()

In finally block...
Press any key to continue

 "(" 7  ( 9   7  18  9 ;" 7   180

 $1
(
2(   
(
 $
9 
=  (1   "( )77 * ;(    1 9    18 "  "( )  
7*  180  ;(4 9  9   18U   7    !"7 ;( 4
  7    = ;O"O7 ;(      7    ;( );( *0
1   = ;O"O7 ;(   9    7   9  ;  " 7 
  7    0 & " 7    ;  1    4     F"   7
 0   19    " 7 "(  180

static void Main()
{
string s = "Faraz";
int []i = new int[3];

/'





   



try
{
Console.WriteLine("Entering the try block...\n");

// can cause NullReferenceException


Console.WriteLine("Lower case name is: " + s.ToLower());

// can cause NullReferenceException or IndexOutOfRangeException


Console.WriteLine("First element of array is: " + i[0].ToString());

// can cause DivideByZeroException


i[0] = 3;
i[1] = 4/i[0];
Console.WriteLine("\nLeaving the try block...");
}
catch(NullReferenceException e)
{
Console.WriteLine("\nIn catch block...");
Console.WriteLine("NullReferenceException Caught");
}
catch(IndexOutOfRangeException e)
{
Console.WriteLine("\nIn catch block...");
Console.WriteLine("IndexOutOfRangeException Caught");
}
catch(Exception e)
{
Console.WriteLine("\nIn catch block...");
Console.WriteLine("Exception Caught");
Console.WriteLine(e.Message);
}
}

 9   "    II       0   7        '0    (
  ( 9 9 9  "  "  7 ;( 

 II   II  1 "4 "   !"7 ;( 0
 &    II  "  = ;O"O7 ;(
    7 6 1 S,T  "  + e;( 7  " 7 S,T  0

/6





   



$       18    7  7  ( 7 ;( 0 !    
18         ;( ;( !"7 ;(   = ;O"O7 ;( 4
9    1 " 1  0

O    7  ;(   1 4 9 9    ;" 7   18   9  7 
;"   (   180 $  1    ;" 9 9   79  "("

Entering the try block...

Lower case name is: faraz


First element of array is: 0

Leaving the try block...


Press any key to continue

 7  000  ;(  "0 % " 7 8    7   "     770


static void Main()
{
string s = null;
...
}


 "(" 9 1

Entering the try block...

In catch block...
NullReferenceException Caught
Press any key to continue

= 8      "  ;(0 !9      ;   " 7 1"  " ) 
      F"  '*0 &      II  (         
!"7 ;( 0

Console.WriteLine("Sixth element of array is: " + i[5].ToString());


 "(" 9 ;( 1

Entering the try block...

/-





   



Lower case name is: faraz

In catch block...
IndexOutOfRangeException Caught
Press any key to continue

        "     ;   8  " 7 S,T F"    " 
+ e;(
000
i[0] = 0;

000
 "(" 7  ( 9 1

Entering the try block...

Lower case name is: faraz


First element of array is: 0

In catch block...
Exception Caught
Attempted to divide by zero.
Press any key to continue

 ;" 7 '<S,T  "  + e;( 0  "  8 7  (  7  
180 =    18  7"   ;( 4 9   "( ( 7  + e;( ) 
   ;(  0!*0  ;" 9   7   (    180

/(  (     


(
 $
9  
  ;(   (   0!     1@4  79     0     7
" 9   18     1  ;( 4  9 "    7  "1.I ;( 0
&(      7  "1. ;(  ;( 7  (   ;( 4 9 "  (
 0  ;(4    79  

static void Main()
{
string s = null;
try
{
Console.WriteLine("Entering the try block...\n");
// can cause NullReferenceException
Console.WriteLine("Lower case name is: " + s.ToLower());

//





   



Console.WriteLine("\nLeaving the try block...");
}
catch(Exception e)
{
Console.WriteLine("\nIn catch block...");
Console.WriteLine("Exception Caught");
Console.WriteLine(e.Message);
}
catch(NullReferenceException e)
{
Console.WriteLine("\nIn catch block...");
Console.WriteLine("NullReferenceException Caught");
}
}

4   18     ;( ( ;(  ( (   "1. ;(
)!"7 ;( *0 !94   9 ;(      184  9 9 1 " 1
 7  184 8      18 : : .     1 0  ( 
   ("   9 9 (  (  (0


A previous catch clause already catches all exceptions of this or a super type
('System.Exception')

 4   "        7 77  ;(  9 "  "(  180

 $ (  (   2( 3


 
=  (1  9   7  ;(       (  9"      
7 4 8 

catch(NullReferenceException)
{
...
}

9 4 9 9" "  "    0



=   (1  9     89 9" ( 4 9      
;( ( ;(      ;( 

catch

/3





   



{
...
}


$ 9"      "   " 4 1"  "  ;(      ;( 4
8 

catch(Exception e)
{
...
}

40'  2(  


=  (1    7  " 9 " ;(    7  "  7 " ;(     "
0 &  4 ;(   (        1@0     7   9
" ;( 4   " 7   9  7 0 " 17 "    9 9  7  " 9
;( 4   (   "        7 1 ;(    0! 7980

2( 3  $' $   9


  9 ( 7 ;(   0!

 ;(    1  "  ) % " " *    ;( 0
 ;(    1  "I (   &(( ;( 0

 (  7 ;(    0! 798  9   79  0

$# %

&'($# % 2%%  $# %

$# %)
*+' $# %)
*+'
,-(./0,1 -
%

(


        

 4   " 7  ;(  " 1   7  &(( ;( 0 =  79 
4 9 9   9  7  " 9 " ;(  = &" ;( 0 $ 9

/C





   



"  ;(  " + )* 4 9     4 9    "   0  
 7  " " ;( 4 = &" ;( 4 

class InvalidArgumentException : ApplicationException
{
public InvalidArgumentException() : base("Divide By Zero Error")
{
}

public InvalidArgumentException(string message) : base(message)


{
}
}


O" " ;(  = &" ;(  1   7 &(( ;( ) 1 7
 " 7  ;( *0 =  1 7  4 9   7    9  "0 O  8 
" 4 9   8    II   " 0    " (    
1   "4 9    E (( )  (    ;( * 9 
"((  0 !9  9   7  " 9 " ;( 4     " 0

$ 2( B $ $ 9' 


&   9  ;( "   9 890 $ 9 9   9  + )* 
 9  = &" ;( 9    "   0

static double Divide(double a, double b)
{
if(b==0)
throw new InvalidArgumentException();
double c = a/b;
return c;
}

4  + )*  9 9  = &" ;( 9    "   7"   1
0 !   + )*     9  9 1@ 7 ( = &" ;( 0
&  4    7   9  9 9   ;( 4 8

throw new InvalidArgumentException("Error: The second argument of Divide is zero");

/5





   



!9  E )*  9 "       ;( "   000 180

static void Main()
{
try
{
Console.WriteLine("In try block...");
double d = Divide(3, 0);
Console.WriteLine("\tResult of division: {0}",d);
}
catch(InvalidArgumentException e)
{
Console.WriteLine("\nIn catch block...");
Console.WriteLine("\tSystem.InvalidArgumentException caught...");
Console.WriteLine("\tMessage: " + e.Message);
}
}


        ;(4 ;(  9 9    ;(   9   7 0
$  (  ;"4  79  "("   

In try block...

In catch block...
System.InvalidArgumentException caught...
Message: Divide By Zero Error
Press any key to continue

!    E ( "  " 9 " 0  (  (  1" 7   "
9 ;(

 =        0! 798    7  ;(    9  9 I;( I
8 ;( 4 !"7 ;( 4 = ;O"O7 ;( 4 0
 4 9 9"
    79        0
 &9   " " ;( 7  &(( ;( 0
     9  ;(    (7   4       ( 
(  9 "  ;( 0

3,





   


-4
  %5 

 &

 9 9 ;(   ( 7      0 $ 9  " 1 8     1 
   9  9   "  0 %4 9 9 ;( "    
 7 0  4 9 9  1"                " 0

4
  7  
+  7   0  7 9   " 7   1@4 00 8  ] 9 8)*U

    7    1@ 7  8  (0


 4  7   9 (( 0  ( 7
1@ )*  7   (  0 0  " 1@ 7  ) (  * 1  7 0

+    1@ 7 4 1"  "  7     7 1@0  ( 7 
   (   " 7      0
      ((

0  (   " 7       (  
0   7  9  1 "  7   
'0  "  7  1  


 &         !)) 

23+  6 2+ 4


,4
  %
 -
'%

6 2()4
25  
%
 -
'%

$ '(    0 $ $ $


 (  
7 "   4 9   (7  (   " 7      7 0 
 " 7    "  " (    ( 7 ( 9  F"  1 (0

3





   



 ;(

int someMethod(string [] args)


=    " 7  E )*  7   ( 7  

int Main(string [] args)
{
...
}


&  7  79  &)* 

int Add(int a, int b)
{
return a+b;
}


  " 9 1

int aMethod(int p, int q)


$     " 7 79  "1)* 

int Subtract(int c, int d)
{
return c-d;
}


= " 1  7  1  ;(    7      ( 7   "U 
 "       " (   (0

=  7 4 9 7   ( 7   "    894 00

delegate int MyDelegate(int p, int q);

 9   7    ( 9   IE+I0  7  7   (  1 "
 (      9 8 9    (   "     "0

3





   



$
  0 + $     0  $
O  9   7    (4 9     7  "  9    "0 &
 7   1  @" 8  1@ 7 0  ;(4  7  7 ( E+
)7  1 *  1  

MyDelegate arithMethod;


  7  E  9 7     9  "       " 7
E+0

$ 
 $ 0  ' $
 
  7   1   7     9     " 1 (     
( 7 

arithMethod = new MyDelegate(Add);

4  E  7     (    &)*  1 (      (
   ( )E+*0   9 (  1        4 8  .

MyDelegate arithMethod = new MyDelegate(Add);

 $ 
 $ $ $ 
 
O    7  IEI  1   (    &)* 4   1 "   
"  8  .

int r = arithMethod(3, 4);


 ( "  7  (  (  190

using System;

namespace CSharpSchool
{
class Test
{
delegate int MyDelegate(int p, int q);

static void Main()


{
MyDelegate arithMethod = new MyDelegate(Add);

3'





   



int r = arithMethod(3, 4);
Console.WriteLine("The result of arithmetic operation `+' on 3 and 4 is: {0}", r);
}

static int Add(int a, int b)


{
return a + b;
}
}
}


 " 7  1  ( 9 1

The result of arithmetic operation `+' on 3 and 4 is: 7
Press any key to continue

 1  (  1       (  1  1  "0

using System;

namespace CSharpSchool
{
class Test
{
delegate int MyDelegate(int p, int q);
static void Main()
{
MyDelegate arithMethod = null;

Console.WriteLine("Which arithmetic operation you like to perform on 3 and 4?");


Console.WriteLine("Press + for Add ");
Console.WriteLine("Press - for Subtract ");
Console.Write("Press m for Maximum Number ");
char choice = (char) Console.Read();

switch(choice)
{
case '+':
arithMethod = new MyDelegate(Add);
break;
case '-':
arithMethod = new MyDelegate(Subtract);

36





   



break;
case 'm':
arithMethod = new MyDelegate(Max);
break;
}
int r = arithMethod(3, 4);
Console.WriteLine("\nThe result of arithmetic operation {0} on 3 and 4 is: {1}", choice, r);
}

static int Add(int a, int b)


{
return a + b;
}

static int Subtract(int a, int b)


{
return a-b;
}

static int Max(int c, int d)


{
if(c>d)
return c;
else
return d;
}
}
}

 9   7    9    "U &)*4 "1)*   E;)*0 &  ( 
E+  7     7  +  (      9     "0 
 7  I+I  "  (  "  ("  1   "  ("  " 0 
( "(" 7   

Which arithmetic operation you like to perform on 3 and 4?
Press + for Add
Press - for Subtract
Press m for Maximum Number -

The result of arithmetic operation - on 3 and 4 is: -1


Press any key to continue

3-





   



 4   "(" 1 4  " ( I.I4   7     7      "1)*
0  1  ( 9     7   1 "  (   "  
     "      " (7 1   (0

0   


'
2 7" 4    II  " 7 1 I (I   I 7 I4 9 
  7"   I  0   8 7 4 9    "" "    I (I
  I 7 I   9       " 0

4
   $   9
&"  (     89     7   "  "4  0!   ( 
  7  (4       7  0+ (0
 4  4 " (
7    I    7    I   F" (((0 &    7  (
  7 0+        1 "    9    "0 & 
(           7          9 "1.( 7 0+4
    1 7  9   )9   " 7   (*0     9 9
  7    E+ "  E )*    ;(  7   0

class Test
{
delegate int MyDelegate(int p, int q);
static void Main()
{
MyDelegate arithMethod = null;
...
}
}

& 
    $ 
#" 8  7    1@  1 (   1@4   7  7     1 (
   0  ;(4  8    I7&O( )*I4 9 8 9  
    7  7 ( E+4      ("  "   9  0

static void PerformArithOperation(int a, int b, MyDelegate arithOperation)
{
int r = arithOperation(a, b);
Console.WriteLine("\nThe result of arithmetic operation on 3 and 4 is: {0}", r);
}

3/





   



!9   E )* 4 9 9    

PerformArithOperation(3, 4, arithMethod);

 4  8 7     (    "  1  )  7*  
7&O( )* 0  ( "  7  (  9 190

using System;
namespace CSharpSchool
{
class Test
{
delegate int MyDelegate(int p, int q);
static void Main()
{
MyDelegate arithMethod = null;

Console.WriteLine("Which arithmetic operation you like to perform on 3 and 4?");


Console.WriteLine("Press + for Add ");
Console.WriteLine("Press - for Subtract ");
Console.Write("Press m for Maximum Number ");
char choice = (char) Console.Read();

switch(choice)
{
case '+':
arithMethod = new MyDelegate(Add);
break;
case '-':
arithMethod = new MyDelegate(Subtract);
break;
case 'm':
arithMethod = new MyDelegate(Max);
break;
}
PerformArithOperation(3, 4, arithMethod);
}

static void PerformArithOperation(int a, int b, MyDelegate arithOperation)


{
int r = arithOperation(a, b);
Console.WriteLine("\nThe result of arithmetic operation on 3 and 4 is: {0}", r);

33





   



}

static int Add(int a, int b)


{
return a + b;
}

static int Subtract(int a, int b)


{
return a-b;
}

static int Max(int c, int d)


{
if(c>d)
return c;
else
return d;
}
}
}

1
 4
  
& ( 7" 7          ("      7   
 "0  8  7    IE" +I0 =  4 "   "1.( 7
0E"+4 9 7   "1 7 0+0   (  (   1
1" "    :  " ( 7  "  ( " 1 :0   7 
    "     "(      0       )
*    "      "4  "  ( "     " (0

(
 1
 4
 
& "   7   ;   9   ( 4 9  ;(   " (
7  "    0

delegate void MyMulticastDelegate(int p, int q);


 77      " I    1 "  IA]I    (4 8 

MyMulticastDelegate arithMethod = null;
arithMethod = new MyMulticastDelegate(Add);

3C





   



arithMethod += new MyMulticastDelegate(Subtract);
arithMethod += new MyMulticastDelegate(Max);


   7  "       7      ;(    "
    (" 0

arithMethod(3, 4);


 ( "  7  ;(  9 190

using System;
namespace CSharpSchool
{
class Test
{
delegate void MyMulticastDelegate(int p, int q);
static void Main()
{
MyMulticastDelegate arithMethod = null;
arithMethod = new MyDelegate(Add);
arithMethod += new MyDelegate(Subtract);
arithMethod += new MyDelegate(Max);

arithMethod(3, 4);
}

static void Add(int a, int b)


{
Console.WriteLine("The sum of 3 and 4 is: {0}", a+b);
}

static void Subtract(int a, int b)


{
Console.WriteLine("The difference of 3 and 4 is: {0}", a-b);
}

static void Max(int c, int d)


{
if(c>d)
Console.WriteLine("The Maximum of 3 and 4 is: {0}", c);
else
Console.WriteLine("The Maximum of 3 and 4 is: {0}", d);

35





   



}
}
}


!  9      &)*4 "1)*   E;)*         " (   ( 
"  " 7  (  (  9  1 7  0  "(" 7  ( 

The sum of 3 and 4 is: 7
The difference of 3 and 4 is: -1
The Maximum of 3 and 4 is: 4
Press any key to continue

!          8  7   (" 0   (  "  
        7 0!4 1     4 9          )9
     7* "  " 0

85 $0  $


 
 G 5 
 
#"  9      " I    "  IA]I (4 9     
7  " I    "   I.]I (0      E )*  7 
( " ( 9 190

static void Main()
{
Console.WriteLine("Adding 3 methods to the multicast delegate...");
Console.WriteLine("==================");

MyMulticastDelegate arithMethod = null;


arithMethod = new MyMulticastDelegate(Add);
arithMethod += new MyMulticastDelegate(Subtract);
arithMethod += new MyMulticastDelegate(Max);

arithMethod(3, 4);

Console.WriteLine("\nRemoving Subtract() method from the multicast delegate...");


Console.WriteLine ("==================================);

arithMethod -= new MyMulticastDelegate(Subtract);


arithMethod(3, 4);
}

C,





   



 9       )&)*4 "1)*   E;)**   " 
IEE"+I    8  0 %4 9    "1)*  7  "
    8   0  "(" 7   9 1


Adding 3 methods to the multicast delegate...
=============================================
The sum of 3 and 4 is: 7
The difference of 3 and 4 is: -1
The Maximum of 3 and 4 is: 4

Removing Subtract() method from the multicast delegate...


=========================================================
The sum of 3 and 4 is: 7
The Maximum of 3 and 4 is: 4
Press any key to continue

 "(" 9   "1)*   1   7  I        
9     8    0

5 5 3



        (( "   ;" 7  (   (( 9  1 7
1"4    ( 0 &     1  " 84  88     7    )*0 &
    1   9    1 7   9  (   "0 &  
        I    I4              I    "I    
9  "     ("       I    I0


 1
   6 5  /
76&$  
.5    
  !"  *    +      

  
      .5  71'
&'       $    $ 82 $  
9            :8 

5 3
 
= 0!4     (   " 0 =       7  )1*  "  "4  
 7  "      890  ( 7 (              

0+7   ("1  7     "    1" 0       " 7   7 
   

C





   



public void EventDelegate(object sender, EventArgs e)


0+7            0 +7   ("1       "      89   
("1 

public event EventDelegate MyEvent


$        0 $      4  7 "   ""       7
   0    "    "1.( 7 0  &4 9        1 (
      0

class SomeEventArgs : EventArgs
{
...
}


&        8 

SomeEventArgs someData = new SomeEventArgs(/*some necessary arguments*/);
MyEvent(this, someData);


O 7     1  4       8 

MyEvent(this, null);


'0+7          0    ""   ((       E )* 
$          0   " 7       " 1     7 
("1    ( 0   7             9  9 :O :4
00

public void OnMyEvent(object sender, EventArgs e)
{
// handle the event
}


=            (  8 

EventClass eventObj = new EventClass();


&       9   "          I   0

C





   



eventObj.MyEvent += new EventDelegate(OnMyEvent);


!9       IO E  )*I 9 1  " 9       IE  I  0

/
9 2(

 ( "   9     (     4 I 8     :8 : ;(0
 8             7      "   0  9 7 
 ("1  7    4    I   I

public delegate void TimerEvent(object sender, EventArgs e);


!9 9 7     I8 I       0

class ClockTimer
{
public event TimerEvent Timer;

public void Start()


{
for(int i=0; i<5; i++)
{
Timer(this, null);
Thread.Sleep(1000);
}
}
}


        4 I I4 7 (    0 =  )* 4     I I  
   7   7 - 0
4 9   "  ()*  7  0  0  4
9 8  "1 7    "   9 1 "(    " 0 $ 9 ;(
     "     0

!; 9   7     9      "    4 9  7  

class Test
{
static void Main()
{
ClockTimer clockTimer = new ClockTimer();
clockTimer.Timer += new TimerEvent(OnClockTick);
clockTimer.Start();

C'





   



}

public static void OnClockTick(object sender, EventArgs e)


{
Console.WriteLine("Received a clock tick event!");
}
}


           4 IO 8 8)*I4 9 79  8   I  "0
=  E )*  7  4 9        7        I8 I0 % 9
 ) "11*  O 8 8)*        I I    7  8  0  4
9     )* 4 9 9   ( 7         8  0 
( "  7  (  9 190

using System;
using System.Threading;

namespace CSharpSchool
{
class Test
{
static void Main()
{
ClockTimer clockTimer = new ClockTimer();
clockTimer.Timer += new TimerEvent(OnClockTick);
clockTimer.Start();
}

public static void OnClockTick(object sender, EventArgs e)


{
Console.WriteLine("Received a clock tick event!");
}
}

public delegate void TimerEvent(object sender, EventArgs e);

class ClockTimer
{
public event TimerEvent Timer;

public void Start()


{

C6





   



for(int i=0; i<5; i++)
{
Timer(this, null);
Thread.Sleep(1000);
}
}
}
}


!  9     "  0   (    7  (4  9  "  
   " 0  "(" 7  ( 

Received a clock tick event!
Received a clock tick event!
Received a clock tick event!
Received a clock tick event!
Received a clock tick event!
Press any key to continue

   (  9   7       7    (   0

1
 5 
      (   "   4 9  "11 "(         
  0  ;(4       

class Test
{
static void Main()
{
ClockTimer clockTimer = new ClockTimer();
clockTimer.Timer += new TimerEvent(OnClockTick);
clockTimer.Timer += new TimerEvent(OnClockTick2);
clockTimer.Start();
}

public static void OnClockTick(object sender, EventArgs e)


{
Console.WriteLine("Received a clock tick event!");
}

public static void OnClockTick2(object sender, EventArgs e)

C-





   



{
Console.WriteLine("Received a clock tick event in OnClockTick2!");
}
}

 9    "       4 IO 8 8I4     "11         
 E )*  "   IA]I (0  "(" 7  ( 

Received a clock tick event!
Received a clock tick event in OnClockTick2!
Received a clock tick event!
Received a clock tick event in OnClockTick2!
Received a clock tick event!
Received a clock tick event in OnClockTick2!
Received a clock tick event!
Received a clock tick event in OnClockTick2!
Received a clock tick event!
Received a clock tick event in OnClockTick2!
Press any key to continue

&  1    "(" 1 4 9 1  O 8 8)*   O 8 8)*   8   
    0

&    $ $5 B* E


 *' 5 /  
 4 9  (     7 9      0  4 9   (7 
79   (

0 +7       7 0  &
0  ("    1 ( 9     9   )(71 "  ((*
'0      7             (  9    

%I 9   " ( " 8  ;(             F"  "1 7
 8 80  9   7   9  I8 &I4 9   7  0  &
0

public class ClockTimerArgs : EventArgs
{
private int tickCount;
public ClockTimerArgs(int tickCount)
{
this.tickCount = tickCount;

C/





   



}
public int TickCount
{
get { return tickCount; }
}
}


 8 &      (  1  I8" I    "  8 "10 
"  (   1@ "  ("1  "    1        "  ("1
((0 !; 9       7  7     

public delegate void TimerEvent(object sender, ClockTimerArgs e);


 "  (       7   &  8 &    ("1 )  
 *  (  (" ( 7 "    "11 )    *0        
7  

class ClockTimer
{
public event TimerEvent Timer;

public void Start()


{
for(int i=0; i<5; i++)
{
Timer(this, new ClockTimerArgs(i+1));
Thread.Sleep(1000);
}
}
}


            7 (  "     " 4 9  (   9 1@ 7
 8 & ( 9  F"  "1 7  "  8 80  4        9

public static void OnClockTick(object sender, ClockTimerArgs e)
{
Console.WriteLine("Received a clock tick event. This is clock tick number {0}", e.TickCount);
}

 9   ( (   8 8 "1 "   8 &I 8"  (0  (
"   9 190

C3





   




using System;
using System.Threading;

namespace CSharpSchool
{
class Test
{
static void Main()
{
ClockTimer clockTimer = new ClockTimer();
clockTimer.Timer += new TimerEvent(OnClockTick);
clockTimer.Start();
}

public static void OnClockTick(object sender, ClockTimerArgs e)


{
Console.WriteLine("Received a clock tick event. This is clock tick number {0}", e.TickCount);
}
}

public class ClockTimerArgs : EventArgs


{
private int tickCount;
public ClockTimerArgs(int tickCount)
{
this.tickCount = tickCount;
}
public int TickCount
{
get { return tickCount; }
}
}
public delegate void TimerEvent(object sender, ClockTimerArgs e);

class ClockTimer
{
public event TimerEvent Timer;
public void Start()
{
for(int i=0; i<5; i++)
{

CC





   



Timer(this, new ClockTimerArgs(i+1));
Thread.Sleep(1000);
}
}
}
}


$  1  (  (   ;"4 9 9   79  "("

Received a clock tick event. This is clock tick number 1
Received a clock tick event. This is clock tick number 2
Received a clock tick event. This is clock tick number 3
Received a clock tick event. This is clock tick number 4
Received a clock tick event. This is clock tick number 5
Press any key to continue

&  "(" 7  ( "4 9 9       8 8 "1   9    0

C5





   


6  %6 /((


  

 &

 9 9  1"  $ 9 &((   0 $ 9  1 8    " 7 $ 9
&((    "((  0!0 %4 9 9  " 7 :
 $ : &((    1"
" 9 9 7  0  4 9 9 8  9 N" "0!    7 $ 9
&(( 0

6 /((
   
   0! (  ;   "(( 7 1"  $ 9 &(( 0   (  (  1"
9 9 ((      I     I0 & 9 9 ((  (   (  7  
"   (   "   0  ( "  7    I$ 9 I4  I$ I 7
0 & 9 9 7    ; 14 (" 1" 4 ; 1;4  1;4 4  "     
7   0 = 74  $     9 9   @" 8  ; 1;4 14 0 = 0!4  9 9
   (  1 1  1@      0$ 90 (0

6 7  
&  4 0! (   $       " 1   
0$ 90 (0   0$ 900   1  7  $  
0!0 =     9 9 (( 4 9  

0  $ 9 &(( (@  N" "0!4   7   0$ 90  
0+9   " "  (@0 =7 "   "  N" "  4 "  <7  ( 7 
    (    10

0$  9   (   $       7  0$ 900 

class MyForm : System.Windows.Form
{
...
}


'0=   "  4   ((( ((      EI    0

60$         E )* 0 =  E )* 4   0&(( 0" )*
4 "((   9     7 E0

5,





   



class Test
{
static void Main()
{
Application.Run(new MyForm());
}
}


 &(( 0" )*   " 7   9 9 ((   (      
      7  $ 9 O(  0

7
 $H3

6 H/((
 
%I 1" " 7 9 9 (( 4 9 9 9  :
 $ :0  (( 9 (  
( 9 9 9  :
 $ :      0  "  7  ( 

using System;
using System.Windows.Forms;
using System.Drawing;

namespace CSharpSchool
{
class Test
{
static void Main()
{
Application.Run(new MyWindow());
}
}

class MyWindow : Form


{
public MyWindow() : base()
{
this.Text = "My First Windows Application";
this.Size = new Size(300, 300);

Label lblGreeting = new Label();


lblGreeting.Text = "Hello WinForm";
lblGreeting.Location = new Point(100, 100);

this.Controls.Add(lblGreeting);

5





   



}
}
}

A  $ 


&  4 9  "  (  " ((

using System;
using System.Windows.Forms;
using System.Drawing;


  (4  9    7  4       7   (( 0 = 74
 &((   9 "    E )*   7    (0 
0$ 90 (     1  7 9 9  4 00 4 %1   " 0
 4  "   0+9  (             9  7
 0        "    (  " 7    0+9 
(0

%4 9    9 4 IE$ 9I4 7    7   0$ 900

class MyWindow : Form
{
...
}


=   " 7 E$ 94 9 (7      7  7 )1       ; ((*0
   7  "   0+9  (I  0 $ ( 9      " 7
  (7  9     7  70

public MyWindow() : base()
{
this.Text = "My First Windows Application";
this.Size = new Size(300, 300);


!;    "4 9   ; 1          7  0 & ; 1 
"  9  ;   70  0$ 900%1  7   ; 1   $ 9
(( 0 $   ; 7  %1 "   ; ((4 9  7    (0 &   
   1  7 " 1       U   9     " 1    0

public MyWindow() : base()
{

5





   



this.Text = "My First Windows Application";
this.Size = new Size(300, 300);

Label lblGreeting = new Label();


lblGreeting.Text = "Hello WinForm";
lblGreeting.Location = new Point(100, 100);

this.Controls.Add(lblGreeting);
}


 4 9            E )* 0 =  E )* 4 9      
E$ 9    (  7    &(( 0" )*        7 
$ 9 O(  0

$ 9 ;"  1  4  79    (



   (( 4 (   1"    10

/5 3

%I 9   1" 1 I;I   70  I;I 1" 9   (( 9   80 =
0!4 " "      7  0$ 900" 0     9 
1" 84 9             ) *    " I 8   0 9  
 7  (( 0

5'





   



using System;
using System.Windows.Forms;
using System.Drawing;

namespace CSharpSchool
{
class Test
{
static void Main()
{
Application.Run(new MyWindow());
}
}

class MyWindow : Form


{
public MyWindow() : base()
{
// Form
this.Text = "My First Windows Application";
this.Size = new Size(300, 300);
this.StartPosition = FormStartPosition.CenterScreen;

// Label
Label lblGreeting = new Label();
lblGreeting.Text = "Hello WinForm";
lblGreeting.Location = new Point(100, 100);

// Button
Button btnExit = new Button();
btnExit.Text = "Exit";
btnExit.Location = new Point(180, 180);
btnExit.Size = new Size(80, 30);
btnExit.Click += new EventHandler(BtnExitOnClick);

// Adding controls to Form


this.Controls.AddRange(new Control[] {lblGreeting, btnExit});
}

public void BtnExitOnClick(object sender, EventArgs e)


{
Application.Exit();

56





   



}
}
}


=   " 7 E$ 94 7 9     (( 7  0 =  4 9    "
  (( 7  4 9   ( 7  7    9  ((
0  ( 7  ((    "  I I0 $      ( 7 
7     7   0

 9  "      ; 1"  I1 ;I0 $     1" "   1 
0$ 900" 0 %4 9    " (( 7  1" 4 (7  ; 1
) ;*4  %    0  4 9           7  1" 
 ;O 8)*0 =   ;O 8)* 4 9   9    ;  (( 0 $   
"11         1 ;I 8    )  "           4   , 7
  *0 =   4 9    1  1    1"   7I    0 ! 
  9   "  & )*  7 7      7       
7 70   8   7 (     (0

$    " 4  79  9 9 9 1 (



!9 "  (   ; "    1"   1  ;  (( 0

5-





   


? 
*  % 4:   45
( 5  ;
E 7  4 " 9 1 "  N" "0!   ( $ 9 ((   0 N" "0!
(    7   (  ( ((    " "   7 98 7  (0 N"
"0! (         =+ 7  0! (( 4   9    1"4
(@   "  4 7  4   (    7  "7" 0

 

* 3  (


 
 N" "0! =+ (     ;   9 0! (( 0  ;    9
=       (0 =      ;   1  " 77  (   
(   ;0  ;(4 9 " (   7   7  1@4  =+ "
(  "   7   1 )((4 4 * 7  1@0  79  7" 9
=    98   N" "0! =+0



  (    ;   " (  " (  0  79  7" 9 
" 7   (  98  N" "0!0

5/





   





O  7  (  9 7"  "  N" "0!   7 0 $  7 4 " 
7<" 7   "   A   . 10 2"    1 7<" 7   ( 1" 
)4 4 (4 ((4 *0 Q"   7    9 "     7<" 7 
 9   0    7  "    000  ((  0

    (
 +*
  
 4  
N" "0! (     (  (   ;" " (( "   ( 0
Q"   (    " 7   ( (@   " ) "( 7 7  8 "( 
(( *0 O  "   ( " (( 4 "  1"  "   N" "0! 1"0
Q"        7 " (( "  N" "0!J

 4  
(   "7" 7" 7  N" "0! =+   7  0  7   9 " 
  ( "  7 @" 1 (       7 7  1;0 Q"     7
(( 7  7      "   ( 9 90

 N" "0! =+ " 9     " 7  " (      7
     ((0 Q"   "  =+      "(       7 "  0 
79  7" (    " 9 7  N" "0!  +     77  "(( 
9 90

53





   




Q"    1; 9 9   7    )*    (( 9 9       )* 7
 1   (0  1; 9 "   77     " 70 O      ( 
 74 "     " (( 7  ( 9 90 Q"        
 7    "   "0    ((  1   1 9       ( ( 
)'*   ( $ 90

 1;4 ( $ 94
( $ 94 " ;( $ 94  N9 $ 94 O"("
$ 9    (  9 9  N" " =+  1  7 +8    &"  0 $ 9 
  7 "  ((   9   7" )00    " (         "
8*4    9   7"0 & 9 9  1  7 "  1  1" 8 6   1 
7"0   9 9  9 1 "  7      (  7  7  
9 90     (   8 9 -   1  7"       94 (   "
;( 9 9    0 =7  7  9 9   1  " " " =+4 " 
8  1 7  N9  "      " 10

*
 2(
  
 " ;(    "7" 9 90 = (   7  8 "(  "    ""0 &
"    7   (@    "  8 "(  0! (( 0 & " 
  (@   77  0! 1  " 8 N0!4 N0!   NAA0!0  79 
7" (    ( 7  N" "0! " ;(0

5C





   




 7        1 7    (  (@0 I&((0I    7 7 
(( 0 &1= 70    7      7 1"  "  10 0  
1  7"    7  " 7 7  (0

& 0! "      0 74   (@      0(@ 7    "       0 70
=  (   "     @   "     7 N" "0!     
F"  7   0!  "0 = 74   " (     9 7   (@  " 0

1  $? 


*  4
 E " 2  4 ( 4       (@4 "    " " 70

 E " 2 7 ;         N" " "  0

N9 E "   (  7    1 7 77  N" " 9 9    9 19
     90

@ E " 2 7   77  (( 7  N" " @0 & N" " (@  
 7 7  8 "(    1     1@ 7 )9 9 ;(   ( 7 1
    *0

" E "   "  "  (   1"  " 74 (@  " 0  " 7  1"  
;"1 7    10

+1" E "   " (  " (     N" "0! +1"0 +1"   
( 7 7       (4    1" ( 8  ( 0

+ E "   " (  7 + &  0!

55





   



 E "       7 "7" (  7 7        "   
+  90

 E "      " "7" N" "0! 0

A ? 
*    
 $H3

6 H/((
 
!9 9I    F"8 " 7 N" "0!4 I "  N" "0! =+  1"  :

$ : (( 9 9      0

 & ! 
 7 4 9     9  $ 9 &(( @0  4  N" "0!   8
I!9I@0 = 9 9  79  



  1   4  IN"  @I  @ (   I$ 9 &(( I  (0 $
  7  9 (@ )I%  $ I   1  7"*   ; 1; 1 !0  
 9 " 9    (@ "   9000 "   8 OG0 = 9 9 "  (
7     9    7" 19

,,





   



 " 7  7     1 9 77  7    9 1 0 Q" 1;  
(( 9 9  1 1     9 9   1 10 Q"      
"   N9  "  1     0

* 5  ( (  0 $0 


Q"     7" (( 7  7 "   ( 9 90  4  )8*  7  
  (( 9 9 )=7  (( 9 9   1      ( 4  N9I(
$ 9*0 !9     7  7     7  7I     1     ;  
! ((4  9   79  7"0

,





   


/  
  $ 
!9   %1   7  1;4 (    7      (((0  )8* 
1   7   7  (( 9 94   ; ((  :
 $ :    !
((  I1K I0   7       7  (        " 0 !9
  "   7  1;4 (    7     (((0  )8*  1"
    ! ((  I1 ;I    ; ((  I;I "   (( 9 90  7 "
9 8 8 

,





   


/5 3

!9 9            7  ; 1" 0  4 ( "1 8  ; 1"  
 0  9   9      7  ; 1" I 8      8 "   "  
9   79  7"0



$      (( )&(( 0;)**       0  =+      
     1"     9  ; 1" I 8   0

2  $((


 
  J  I
 $ I ((  (0  (   ;"  (( 4  "I"
" ) ( A7A*     +1"I $" +1"  ) ( A-*0
 9 (     I
 $ I ((   9 9 9  9 19

,'





   





   (( 4 8  ; 1"    1"    1 7  9 90


 ,     .5       * 2 ; 2 
  +    <*+ *+ = 
 #  *+
 $ 

static void Main()
{
Application.Run(new MyForm());
}


E8 "      7  7  E )*  9   "       (
$ 9         ( 0

$   ' $ 4  


Q"   19   +     "  N9I+    N9I0 &7 9   
4 " 9 7      1  7    1     9   9   
 0  "     14 9             1" 0

A 1   

!9 9    7 9  N" "0! =+     4 I  1"    0
!  9 9  ( 7        9      7   
((     0 & " 7  7     (  190

,6





   




  +(
%1 2  (  ;   70 =   7 0$ 900%10 =( 
((  ;4 !    0 2"        7  %1  0
" 2  (  " "   70 =   7 0$ 900" 0
=(  ((  ;4 !    0 2"  8       7 
" 0
;;    " 9    9< ;0 =   7 0$ 900 ;;0
=(  ((  ; )  "( ;    9  "   *4 !4
&  4 E"  )1 *4  )  7  1  9  ; 1;*4
O  )1 *4 $$( )1 *   9 ) " 7 (9
8 *0 =(      ;  )7"*   G0
K"(; 2  "(   0 =   7 0$ 900K"(;0 =( 
((  ;4 N1 )1 *    1 )1 *0 2"       
7  K"(;0
" &9  "     " 7    1 ( 0 "   "" "  
"(      K"(;0 O    7  "  1    "(  
0 =   7 0$ 900" 0 =(  ((  ;4 !
  8 )1 *0 =(      8 0 2"     7 
"    U       7   8 7  ("
1"       0
8; &9  "  8  " 8  1;    (7  7  0 8; 
"" "   "(      K"(;0 & 4     7  81;  
"(  1 0 =   7 0$ 9008;0 =(  ((
 ;4 !4 8 )1 *   80 =(      8 
  8 0

A 5   


((
 B&   G *$((  
!9 I   II ((  I (( 0  I ((       
180  1   1"      18  1 7" (       0  ((
9 7  8 8 

,-





   



& "  4 9   "  K"(; )*4 8; )*4 "  )'*4 ;; )6*4 %1  
"     1  (( 0

4  $0 (


 $ 

 7   N" "0!     9 $ 9 &(( @0   (( 7  7
"   ( $ 9   79  " .

 ] 6/,4 '6,
 ]  
! ] E
; ] I ((  

$    "( ( 7  7    4 !    7 7    1
     ;    7  &(( I $ 90

!9   %1   7  9   7" 1 0   ; (( 7  %1  II
((  I0

!;4 7  1; 9 94   K"(;   70 E7   (((   
81;    10   ; (( 7  K"(;  I& 1 8I    ! (( 
I1;& 18I

  1; 9 94   81;   K"(; " @" 0   ; (( 7  
81;  I   )f,*I4 I7   )f',*I   I  )f-,*I0 &   ! ((
7  81;  I1;I4 I1;7I   I1;I0 &  %1   K"(;     ;
((  I  18 " 9  ("I4  9   7"0

,/





   



&   K"(;4   ; ((  IE 7  I4  ! ((  I1; EI  
  1 ((  II0 E8    1 (( II 9 1  "(1;        
"(4    9   1  1 )"  * 9  "    180 & 9
"    K"(;  9   7"0   ! ((  I1 " I  
I1 =  I0   ; (( 7   1"   I"  I   I=  I0  8  7
( )"  *  7" ( 4   8 ((  "0 &  %1   K"(;    
; ((  I   7 ( I4  9   7"0

&  " 1"   70   ! ((  I1 "I4  ; ((  I"I   
 1 ((  II0 &  " 1" 9 1  1   9  "   
180

&  ;;    %1   70   ; (( 7  %1  I I0   ; (( 7
 ;;  :: )(*4  ! ((  I; I    E"%  ((  "0  ("(
7    E"%  ((  "   9  ;;    ;  (       0 
7" " 7  E"%  ((  0

 4   ; "   70   ! ((  I1 ;I    ; ((  I;I0

6   0 5 3



 7         7  ; " I 8    1 "1 8       0 $ 
79    ;  ((

private void btnExit_Click(object sender, System.EventArgs e)
{
Application.Exit();
}


$  "     184  IE 7  I "( 1;    " 1" " 1  14
  7   18  " 4  " 1 10     1 9        7
8     7  81;0         7  81;4  "1 8 
81;      "1 8  I8 I    7 81;      (( 9 90
 8     7  81;   9    81;  8  " 8  
8 ((   0 $  79          7 7 81;

private void cbxProgCS_CheckedChanged(object sender, System.EventArgs e)
{
if(cbxProgCS.Checked == false && cbxProfCS.Checked == false && cbxCSSchool.Checked == false)
{
gbxPaymentMode.Enabled = false;
btnPurchase.Enabled = false;

,3





   



}
else
{
gbxPaymentMode.Enabled = true;
btnPurchase.Enabled = true;
}
}


=   1  7   81;  " 84 9 1  IE 7  I "( 1;   
" 1" U 94 9  1 0

(   (    7  8     7   9 81; )1;7  
1;* !9 ;"  (   8<" 8 77  81;0 Q" 9  7   7 
81;  84  E 7   "( 1;   " 1"   14   7   7 
81;  84   10

    8    7  " " 4  ( " (  "       7 18
4    7  ("4   7 (          "  ( 0
&  8      7  " 1" 1 "1 8         9  79 


private void btnPurchase_Click(object sender, System.EventArgs e)
{
string message = "You purchased:\r\n\t";
int amount=0;
if(cbxProgCS.Checked)
{
amount+=20;
message+=cbxProgCS.Text + "\r\n\t";
}
if(cbxProfCS.Checked)
{
amount+=30;
message+=cbxProfCS.Text + "\r\n\t";
}
if(cbxCSSchool.Checked)
{
amount+=50;
message+=cbxCSSchool.Text + "\r\n\t";
}

string paymentMode="";

,C





   



if(rbnFullPayment.Checked)
{
paymentMode = rbnFullPayment.Text;
}
else
{
paymentMode = rbnInstallments.Text;
}

message+="\r\nThe total payment due is $" + amount.ToString();


message+="\r\nThe selected mode of payment is: " + paymentMode;

if(txtComments.Text != "")
{
message+="\r\nYour comments about us are: " + txtComments.Text;
}

MessageBox.Show(message, "Summary");
}


$   "  1   1  0    1 "   "     "  7
("4    1 ( E  "      7 (       1
 9   "   9 7  1 (   E;0  9 8 
7  81;   "   " U     9  1"   7 18   
  1 0 $  7"    7 (       )*     10
!; 9      (      (      1 0  4 9
(  "    E ;0 &  1;    9 9  (( "( 9 
0 &  1;    8  7  1;4 9   9   ( "     
 9 9 7 " (( "  "      1;0  E; I  9
      7U    9 " 8     (    1;     7 
 1;0

!9 9 9 ;"  (   (  (" 1" 7    184 9   79 
"("

,5





   




$ ( "        "    7 $ 9 ((    $     0
   8  "  9 9 ( 0   ((  "     
;(  " (74  1     " "    9 10 !     "  
((      7   0 Q" " ;(       " 7  7 "70

*(  & 0  6 /((


  
 E8 " 7 " (     "  0 =  (    " 7 " ((
7   70  1  " 1 ;(   "  "(  "0
    " 7  N" "0! =+   "7" 9     7 "0 = ( 
 "1 7 "7" (  7       7   0
 &         (( 8 % 4 4  14 N14 1= ;4 0
 1= ; ((   ( 0 = 1  F"  79 1  9 9 7" 9
 " (  1 1"   810
    " 1     ("(  1  4 004 9     "
1" I1 "I   ( " ;(0
 &" 9          4   "7"      (7;    7 "
       1 1  0 ""   4 9   79 
   1 (7;   %1  I  9 1 )1K *4 ;; 9 ; ); *4
" 9 1 )1 "*4 8; 9 1; )1;*4 " 9 1
)1 " *   K"(; 9 1; )1; E*0

,





   


1 6   
%*  4
72 

 &

 9 9  1"   9 9        1;0 $ 9  " 1 8  
   4 "   % 1;4 1 1;4  N9   % N9  0 %4 9 9 
1"    4  "     "4  4 1   +  80  4 9 9
;(  7     1;4 00  O( 4   4      + ;0

   

 7  9 9      ( 7  4 8  7 18      70 
    0 ;( 7     "  % ;4 1 ;4  N94 %
N94 14 = %   E E "0 =   9 9 ;(      1  0

 72  

&  1;        7  9  1  1  "0 &  1;  1   9  "
      0 = 0!4   1;  (  1  0$ 900%; 0 
 1;          I=I     (    0 &  )"" 
 *  1     7   1;0

 79    (   9 9       1; )*    1 1; )*0


&  1;  1    7 7  N" "0! 10 2"  1    1   
1;       7   1; )004  1 I& 1 8I   1  ("*0  ! ((
7   1;  "     7   1; 1@   0 0$ 900%;    
((  I=I 9 (            1;0  =   1
"  4       7   1;0







   



/    $
  2
&  1;  1 (("     "   N" " =+   "  "  0  
    1; "   N" " =+4    1;           ((
9 9 8  = ((0 = 9 9 "   7 9 "      7   1  
  1;0

&  4 "  9        1;0 &   1     1; "   &)*
 7  =  7  %; 1@0 &"  9      1;     7
18    9     ! (( 7   1;  I1;8I0  79    1 "  
    1;0

lbxBooks.Items.Add("Programming C#");
lbxBooks.Items.Add("Professional C#");


O 7 " 9      7 4 "  "  & )*  7  = 

lbxBooks.Items.AddRange(new String[] {
"Beginning C# by Wrox",
"Professional C# by Wrox",
"Programming C# by O' Reilly",
"Professional ASP.Net",
"Beginning Java 2 by Wrox",
"C++ - The complete Reference",
"Java Servlets Programming",
"Java Server Pages - JSP)"});

/    $


  2
 =  7   1; (    ; ((  9     1;  1 
( )"  *0

lbxBooks.Items[0] = "Program Development in Java"; // changing list box item
string book1 = (string) lbxBooks.Items[1]; // reading list box item


=  1  4  7   "   ; (( 7  =       1;   
           1;0 !  9   ((      1;   
" ( 7  =  ; )=ST*  1@0

Q"   4  " 4  "    "   = (( 7   1;0

MessageBox.Show(lbxBooks.SelectedItem.ToString());








   



85  0  $
  2
=  "   1   7   1;  1     )*   &)*  7 
=  7   1;0   )*  (  1@  1   7   1; 

lbxBooks.Items.Remove("Programming C#");


 1    9     I  I 7   1;0 Q"   "   &)* 
9 (   ; 7    1   7   1;0

lbxBooks.Items.RemoveAt(0);


   9        ; , ) 7  * 7   1;0  4      
      1;4 "    )* 0

lbxBooks.Items.Clear();

 725 
  (    7F"  "    7   1;  = ; 0      
9        1;0         7    4 "1 8   1;   7
 0

'





   



 79   9 9       1; 9        1; 
 0

private void lbxBooks_SelectedIndexChanged(object sender, System.EventArgs e)
{
MessageBox.Show("The selected item is " + lbxBooks.SelectedItem.ToString(), "Selected Item");
}

 72  

 1 1;      1;     "  (   7 0  1 1;  (  
0! "  0$ 9001; 0  1 1;   "   9  1
 "   1; I I+(+9 I ((0       I(I4 I+(+9 I
  I+(+9 %I0  79        ( 9 0



 (  9   7            ( 0  ( (
9  1 1;  ( "   7   1; )"     *0  +(+9 
9     ( 9 0  "  9  9    ; 0  +(+9 %  
   ( 9  1"   "       7   1      (  
9  70

=  1  4       @"   9  9    1;0

 ?
  N9    " 7  (   7 0=  (   0! 1 
0$ 900 N9 0  79       ;( 7 9   9  
 80

6





   


$   
  9           7   9    "  I!I ((  
7  0 $ " 8  ! ((   (( 9 9 7  7  4  9 9 
79   4 9  8 9    ! 0

-





   




I& I 9      )  9  (  004 $   1  9 9*0 I& I 9  
      0  1 7    1   "   ; 1; 1 I%1I0 & 
 1  "   I+I 1" 0

/I85     
=  1      7   9 "   !    4 1"  7  
9   <    "  "  " 0  N9      ((  I!I
9 (       "  7   0  &)*  7  !   1
"    ;    ! 1@ 9 7      0  79    
(     7I %   0

private void MyForm_Load(object sender, System.EventArgs e)
{
treeView1.Nodes.Clear();
treeView1.Nodes.Add("Programming Languages");
TreeNode node = new TreeNode("Object Oriented Programming Languages");
node.Nodes.Add("C++");
TreeNode subnode = node.Nodes.Add("Framework and runtime based languages");
subnode.Nodes.Add("Java");

/





   



subnode.Nodes.Add("C#");
treeView1.Nodes[0].Nodes.Add(node);
}


 9       1 I  % "I0 $    9 !   
"1   0   9       0 $ 9 ;"  (4  79   
("0

3





   


 ?5 
 N9   "1 7 (    4  7 9   190

   +(
&7  9   ) *      9  0 N9  & 
( 9     9  
* N9&  " 9 1   "   8
G14 E"4 (4 
* ! 1@ 9 (    0
     1  "   ! (( 7   9
 0
7;(   @" 17    ;( 0
7(  @" 17    (0
&7;(   @" 7    ;( 0
&7(  @" 7    (0
7%1  @" 17  (      %1 7  0 Q"    
%1 (( 7   9  " 7 " 9  9 " "    1
7  0
&7%1  @" 7  1 7    1 0

 79       9 9  1 7     E 1; 9     0

private void treeView1_AfterSelect(object sender, System.Windows.Forms.TreeViewEventArgs e)
{
MessageBox.Show("'" + e.Node.Text + "' node selected", "Selected Node");
}

C





   



 ( 9 8 8  9 "

   

      1  0 =   "      1 "    4 "  
 9   9  0 &   )8    "4  ;  "4 1    *  
 " (   "          ( (   " (( 0 =  ( 
 0! 1  0$ 900=% 0

$ "       7  N" "  1;   (    74    
  "    ( 19  7        0 Q"    7     
  ((0

 7"   (( 7      !0 & = %    79 ((0  
(    I=I  4 9        0 $ " 8  =
(( 7  = %  N" "I  4  9     9 9 "  
77  01(4 0@(   07 ("  "    0  I=I (( (    7
    0  7"  /4 /   N" " 9 "    " 7 C,, ; /,,0

/ $/  00   



&      77   4 00   94  9  10   9    1
     ((  =% 9  "       0    "  
    "   1"  9   0  ;(4  &)*  7  ! 

5





   



7   9        9 (  ; 7       ; 7   
   0

 ?  

 % N9      (        0 =  "     7     (
  7" 77  9U % = 4  = 4 %   +0   7" I$ 9 ;(I "
  9    9 77   0 &  9  (   0! 1 
0$ 900%N9 0  79      7" 77  9 7  
9  0  IN9I (( 7   9  "     9 7  9  0

  $ ?  



9    1     9  0 O     %=%      " 7
      90       =%      " 7    
  4     90 2"  9      9  77      =
((0  ;(   1   4   7        '4 ' 9   7
       ,4 ,   9   "    7  9  U  7 9 @"
(.(           7 0

/    $
 5 
   
N" " (    9       9  0       9  4
( 8  I=I (( 7   9   (( 9 90 = 9 (  %N9 
0

,





   


 "  "  & 1"      0     ; (( 9 (   ;
( 9  0      == ; (( 9 (     1 
9  0     7     )&    1  " 
%=%  =% (( 7   9    1 *0 =7 "."  9
 " )9 9 9 1     *4  "1= ((  1 "    "1  7 
0 4   1   "     " 0

/      


 %N9     ((  = 9    7 %N9=  1   
 9  0 =  1     "   &)*    )* 0  &)*  
    0 O  8      9  "  (   ; 7  0     
8          ;0     "  7  ; 1      ;  "  
 ("  7       0     8  %N9= 1@0 
79         9

listView1.Items.Add("Disk"); // text label is passed
listView1.Items.Add("Disk", 0); // text label and image index is passed
ListViewItem item = new ListViewItem("Disk", 2); // a new ListViewItem object is created
listView1.Items.Add(item); // and added to the list view control







   



5 0  ?  

  7F"  "    7   9    = ;     9   9
     9   0  79       (    I ;   
1; 9        9  0

private void listView1_SelectedIndexChanged(object sender, System.EventArgs e)
{
foreach(ListViewItem item in listView1.SelectedItems)
{
MessageBox.Show(item.Text);
}
}

11
E  "      7   "0 E  "  (   0! 1 
0$ 900E E " 0 Q"  @" (8   (  E E "   7  "
" 1;    70 &  " N" " 9 9  (   "   ( 7  70
    7    "    (     " 1 8  0



 (  (  1"   " 

 Q"        ; 7    "  7  (( 9 9 9    
  0
 Q"   (( " 8 )8 A  &A-* 7   "  "   (( 9 90
 Q"  8     )@" 8    19     ; (   1   * 
  " 1 9     .    "  ;0
 Q"    81; 17   "  "   8 ((0
 Q"         7   "  @" 1 "1 8      







   




7 
1    8  " ) "4  4 *0 =  (   0! 1 
0$ 900  0          "  9  1 "
 <   7  10 &     1  9  10 $ " 8 
"  ((   (( 9 94 N" " (  "  7  7      
1" 0       1  7  1 @" 1 "1 8   1"    0

4 &9 
+  8      "   9 9      9  "   (" 0
= 0!   (  1  0$ 900+ 8 0 =  ( 1  7 
1;   (   7    0 2" 9      ! ((0  79  
 9  7       (8  0



  7F"  "    7   (8  N" 0 =   9  "   9
 7   0  79       "      (   " 7     
1;

private void dtpSelectDate_ValueChanged(object sender, System.EventArgs e)
{
string msg = dtpSelectDate.Text;
msg += "\r\n Day: " + dtpSelectDate.Value.Day.ToString();;
msg += "\r\n Month: " + dtpSelectDate.Value.Month.ToString();;
msg += "\r\n Year: " + dtpSelectDate.Value.Year.ToString();;
msg += "\r\n Day of Week: " + dtpSelectDate.Value.DayOfWeek.ToString();;
MessageBox.Show(msg);

'





   



}


=   1 4 9   (    (   4  4     7  98  
 1;0 $  (  ;" 79  "("  "0

6 *  4


72 
$ 9 9  (  (     "  1;   (( 0   " 
O( 4   4    4        1;0 $ 9 "  7 7" 7 
 0   1;      7   " 9     I     (  
" (    (( "(   9  1   (    (( 0

(
4
72
     1; (    $ 9     7 (   70 =      7
0$ 900O( +;0  79    9   ( 7 0

6





   




 (  ((  "

( +(
+7";  7" ;  7 (   70 = " 9   F" 7 7  7 0 =7
 " 7 +7";  X0    7 9 ;  II 9 1 1   (
7 0
!  7" (   7  7   70
= +     )7*  1 (    0
E"  ((0 (  9 "( 7   9  0
+" +"  "  9 9 "    OG     1" 
   1;0

A  $(
4
72
2"  ( 7  1;  (     9  1"  (    "   0 
79  1"      (   ( 7  1;   (    7 7    
1;0

private void btnOpenFile_Click(object sender, System.EventArgs e)
{
DialogResult res = openFileDialog.ShowDialog();
if(res == DialogResult.OK)
{
MessageBox.Show(openFileDialog.FileName, "File selected");
}

-





   



}

 9 7 (    1;    "   9+)* 0   (  
 1;     "   +"  " 9 (  9  "   
1;0 =  ;   9 8 9 "  ( OG 1"     1;0 =7   9 ( 
  7  7    1;0 $  1    ;"4  9  79  "0



=   7  1   1;   ! (( "   ( ( 7   70

*5
4
72
   7  1;  "  9  "         7  7  1  0 =  
   7 0$ 900 +0 =      ( 7  1;0  79 
 9 9    7  1;      (    7  7  1      1;

private void btnSaveFile_Click(object sender, System.EventArgs e)
{
DialogResult res = saveFileDialog.ShowDialog();
if(res == DialogResult.OK)
{
MessageBox.Show(saveFileDialog.FileName, "File saved");
}
}

/





   



  1  9 9  79   1;

  
 4
72 
 7   1;  "  9  "   7   0 Q"      1;  E7
$ 4 !(   E! E 0 =      7 0$ 900 +0  
 1;  "  9  "    0 Q"       1;  E7  0 = 
    7 0$ 900+0  7   1; 8 8 

3





   



&     1; 8 8 



% 8  (( 9 (   7 9  ; 1;  9  0 = 9 9  "   
 7     7  ;   ; 1;0  7 8 8 



 7     9  1;0 O   7 +     7       + 
   0       7 9 1"  

C





   



private void btnChangeFont_Click(object sender, System.EventArgs e)
{
DialogResult res = fontDialog.ShowDialog();
if(res == DialogResult.OK)
{
txtComment.Font = fontDialog.Font;
txtComment.ForeColor = fontDialog.Color;
}
}

private void btnChangeColor_Click(object sender, System.EventArgs e)


{
DialogResult res = colorDialog.ShowDialog();
if(res == DialogResult.OK)
{
txtComment.ForeColor = colorDialog.Color;
}
}


   7  1"      (   7       7     7  ; 7  ; 1;
   7    0 !  9     9 (( 7  7   1;  "4 9 
7 1 7"0 =     1" I     4  ( (     1;    
 7  ;   ; 1;     0

5





   


4 /  /4 

 &

 9 9  9 "  ((     9 1 0 $ 9  " 1 8   
" 7 &+O0!    77  (  0 % 9 9      0! " 
(( 0   9 9  1"  ("   ;(  + K   9   
" 7 9  0

 /4 
E 7 I ((      9 1   (4   9 0 = 0!4  
   (  " &+O0! (  0 &+O0!   1@   798  9 " 
  9 1 0

$ ""   9 1  " R% F"   ("0  1   1"
&+O0!     ; 7;1   77 0 &+O0!   "   ( 7    
"0 =     (  4 "       1    
  9  " R% F" "     0

 ((      +    9    "  +  0    9
"1   ;(   1 "4   7   ((    F"   9  ( 
0 &+O0!    (1 1      1"77 7 (      0

Q" (( "     1   9    "  F"     
 7    " 18        0   7 &+O0!   
   "     "         7
     0 =
" 1   &+O0!  (           0


  + & &"

',





   



&+O0! +  + & &"

&  (  ( 7   "         ( 7    
1@0   1@   14   (    77    0  "  (7
(  8 "(4         4           (( 
 " 1   1 9 0   " 98 77   "  1 (7 0

400  ( 0/4 


7       7 (     ((  "  &+O0!4   (  
"    77  "((  (    0 &    7        
0+ (0

 +(
+  +    1"77 7 1    7    0
+ 1 & + 1  "      1" 7 "  9   " 0
+9 (       9   + 10
+" (   "  7 7  + 10
+ (    ( 19 77  1    00
   (          ((   (" 7  " 0

&+O0!      1 (7 0     77  1  (  
(   )  * ( 7  (" 1 0 E7 7  (  
(   (  7  R%   1 0   7    9 IFI
        0+0F  (0

4 O   (    ) * ( 7  O + 0 E7  
(      9    " ((    O% "(( 1  0  
7    9 IO+1I          0+0O+1 (0 = 74 " 
" O+1      R%    O 1U "   1 (7   
(  ( (7 4 9 0

 +(
'





   



F  4 O+1  (       1 0
F 4 O+1  (  R% F"0
F+&(4 O+1+&( &       1 4 7     7
 0
F+4 O+1+ &     7  1      0
F4 O+1 (   (    ("0

/ 50  *FJ  

 9 (   17  9 7 7" 1 R% F"0


*F* *   


 F"  "    "  7   7     1 10

SELECT * from emp


   7 7    7  1  I(I

SELECT empno, ename from emp


  7 (      7    7  1  I(I

SELECT * from emp where empno < 100


    7  1  I(I 9  " 7  7 (     ,,

SELECT * from article, author where article.authorId = author.authorId


    7  1  II   I"I      " 7  7 "=

*F*8*   
 F"  "         1 10

INSERT INTO emp(empno, ename) values(101, 'John Guttag')


       ( 1     (  7  ,      7  I# K"I

*FA&4/*   
 F"  "  7 ;     1 10
'





   




UPDATE emp SET ename = 'Eric Gamma' WHERE empno = 101


"(   9 (  7  , 1      7  I KI

*F4*   
 F"  "   ;  )* 7  1 10

DELETE FROM emp WHERE empno = 101


   9 (  7  , 7  ( 1

& 0     9  $/4 


 "  9    " J %I    (0 !9 9 9 1"  ((   
9    8  (7 "  &+O0!0

$ 9 "  E R%     E & 1   (7    80 R%   
" 1" (11  7   " 9 1 "  E R%   9  (  0! (( 0

 R%  4 9 9 1 "   7  0+0F  (0 &  " 
   O+1 10  & 9 9 1 "   7  0+0O+1 (0

= 74     77    9 (( 7  (     9     9 1
77   1 0 $ 9   (7   7  9 "    8

// For SQL server
SqlDataAdapter dataAdapter = new
SqlDataAdapter(commandString, conn);


// For Access
OleDbDataAdapter dataAdapter = new
OleDbDataAdapter(commandString, conn);


  ;( 4 9 9 1 "   1  I
  I0  1 9    1
 I&I0  7 7  1 I&I 

 ! ( +(
= ) G*=   " F"  7 7 
     7  
(   (    7   8 IE"  
# I  I I
''





   



"= ) G*=  2 F"   7 "
  =  !0 7     
O7"1  +     9 ("1

 I
  I 1      1  I&"I 9  79  7

 ! ( +(
"= ) G*=   " F"   7  "
   ! 7  "

/ 4  /4 


+  "  &+O0!     79  (

 +7        7  1  
 +7      )F   O+1  *   1 "      
 +7      )F   O+1 *           F"
 +7     ( )F+&(  O+1+&(* "         
  1@
    9 + 1@
 =7     % 4 7    1@ 9  " 7  F" "   (
     7  + 1    "   +9   +" 1@
 =7     2+& 4 =!  +% 4  "(    "   (
 &(             1

  9      ((  " 1 R%     & 1 9    " 
79  (  " ((

using System.Data;
using System.Data.OleDb; // for Access database
using System.Data.SqlClient; // for SQL Server


%I 9 "  7  1  (   "

40 $  


     7  9 1   "  " 4 9  4 " "    (9
  (   1 0

'6





   



 R%  4 9   9  79     

// for Sql Server
string connectionString = "server=P-III; database=programmersheaven;uid=sa; pwd=;";


 7  9   7       7   4 9  .===   0 !; 9 7  
 7  14 "  )"*   (9 )(9*0    R%    I    (9 7 
 &  )* "4 =   7  1 8      0 )Q = 8 9     "  
   1 ( .  4   "  1 8 (9      1    98*
 &4 9   9  79     

// for MS Access
string connectionString = "provider=Microsoft.Jet.OLEDB.4.0;data source = c:\\programmersheaven.mdb";


 9   7   (  7   10  9   7    " 9  
 7   10


 !    
             
     
 

40  


&    7  "      0  1@  " 1   (      
  7  1  R%        8 

// for Sql Server
SqlConnection conn = new SqlConnection(connectionString);


&  7 &      8 

// for MS Access
OleDbConnection conn = new OleDbConnection(connectionString);

 9   (         " 7    1@0

40 $  


       F"  1 (   10
 9  "      0 $ 9 
   1@ )F   O+1 *     0      9   " 
" (( 

string commandString = "SELECT " +

'-





   



"artId, title, topic, " +
"article.authorId as authorId, " +
"name, lines, dateOfPublishing " +
"FROM " +
"article, author " +
"WHERE " +
"author.authorId = article.authorId";

 9   (  F"        9  "I 0 O7 " "  " 
( F"4 " 

string commandString = "SELECT * from article";

40 $4 /(  


!; 9   7    ( )F+&(  O+1+&(*0   (  "
  )F"*     4   "       1 9 84 7  " 7 
F"        0
 R%  4   (   8 

// for Sql Server
SqlDataAdapter dataAdapter = new SqlDataAdapter(commandString, conn);


&  7 &4   (   8 

// for MS Access
OleDbDataAdapter dataAdapter = new OleDbDataAdapter(commandString, conn);

 9     9    7   (   "((           1@
   " 0

 0

 $4 * 


  9        7  +0 & 9    4  +    L 77 
   7 0  + 1@   (

DataSet ds = new DataSet();


!9 9   7  + 9  " 7  F"0 $ 9 "  &( 1@ 7  ("(
    )* 0    ( 9   (     ( 1   7 
" 7  F"0

'/





   



dataAdapter.Fill(ds, "prog");

 9     )*  7 &( 1@0 $   "((     7     7
 1 )+ 1*  9  " 7 F"  70

   9       7  7  10 !9  " 7  F"     
1@   ( 14 9      7  + 10 $    7    1 1 "  
 ; (( 7   1@I 1  0

DataTable dataTable = ds.Tables["prog"];


  ; 9   " 8   7  1      "   (   + 1
1@0 !9 9  "  1 9   "          10

/4  /((
 
%I 9     (( 7   0    9 9 7 ((   8
 " 9  79   (0



$     ! (( 7  ; 1; )7 (  1*  ;&=+4 ;& 4
;& (4 ;&"=4 ;&"!4 ;!"O7%    ;+O7"1 0 & 9    
O  (( 7   ; 1;  "   I 9   "     ;0   7  1" 

'3





   



)7 (  1*  1 % 14 1 !;   1  "0 =  9   1  !;    "
1"  )1     1 ((  7*0

$    7   1    

public class ADOForm : System.Windows.Forms.Form
{
DataTable dataTable;
int currRec=0;
int totalRec=0;


  1 1@ 9 1 "  7   1 "    " 7  F"0  "   
  1  "  8( 8 7  "      "1 7    10

 
 
  % 1 1" 4 9   9  79      

private void btnLoadTable_Click(object sender, System.EventArgs e)
{
// for Sql Server
string connectionString = "server=P-III; database=programmersheaven;uid=sa; pwd=;";

// for MS Access
/*string connectionString = "provider=Microsoft.Jet.OLEDB.4.0;" +
"data source = c:\\programmersheaven.mdb";*/

// for Sql Server


SqlConnection conn = new SqlConnection(connectionString);

// for MS Access
//OleDbConnection conn = new OleDbConnection(connectionString);

string commandString = "SELECT " +


"artId, title, topic, " +
"article.authorId as authorId, " +
"name, lines, dateOfPublishing " +
"FROM " +
"article, author " +
"WHERE " +
"author.authorId = article.authorId";

'C





   



// for Sql Server
SqlDataAdapter dataAdapter = new SqlDataAdapter(commandString, conn);

// for MS Access
//OleDbDataAdapter dataAdapter = new OleDbDataAdapter(commandString, conn);

DataSet ds = new DataSet();


dataAdapter.Fill(ds, "prog");

dataTable = ds.Tables["prog"];
currRec = 0;
totalRec = dataTable.Rows.Count;

FillControls();

btnNext.Enabled = true;
btnPrevious.Enabled = true;
}


 9     4  (   7   1@4  7 9 9   " 0 =
" 1   9     "   7  O+1 (  )E.&*    "  R%
  (7 0 =7 " 9" 8  "  & 14 "  (    R%   
"   .   & 0

!;4 9       1 "  7  F"    1 1@ 9 9   
  4     " 1      "1 7 9    1 

the totalRec variable:
dataTable = ds.Tables["prog"];
currRec = 0;
totalRec = dataTable.Rows.Count;


 9    )* 4 9 7    ); 1;*   7 9  "  
7  1 :(:0   9  1  !;    " " 0



 $ 
 $ 
  )*   " ( 7      7 9  "   7   10
   7   79

private void FillControls()
{

'5





   



txtArticleId.Text = dataTable.Rows[currRec]["artId"].ToString();
txtArticleTitle.Text = dataTable.Rows[currRec]["title"].ToString();
txtArticleTopic.Text = dataTable.Rows[currRec]["topic"].ToString();
txtAuthorId.Text = dataTable.Rows[currRec]["authorId"].ToString();
txtAuthorName.Text = dataTable.Rows[currRec]["name"].ToString();
txtNumOfLines.Text = dataTable.Rows[currRec]["lines"].ToString();
txtDateOfPublishing.Text = dataTable.Rows[currRec]["dateOfPublishing"].ToString();
}

 9     ; (( 7  ; 1;     " 7  (   7 7  " 
0 $   "  9  7   1   "    ; 9     +9
(    "  0 $       ; (( 7  +9 "   "
       (  70 =7  ;(  8 9  "4 "  (7  1 
   .

DataRow row = dataTable.Rows[currRec]; // getting current row
object data = row["artId"]; // getting data in the artId field
string strData = data.ToString(); // converting to string
txtArticleId.Text = strData; // display in the text box


9  F"   

txtArticleId.Text = dataTable.Rows[currRec]["artId"].ToString();

  9 "   ((   (  % 1 1" 4 " 9   79  "("


6,





   



5  $ $ $   
!   "      0   !; 1" 4 9   9  79  (   
 


private void btnNext_Click(object sender, System.EventArgs e)
{
currRec++;
if(currRec>=totalRec)
currRec=0;
FillControls();
}

 9 7       1 "   8 7       )"   
1*   10 =7  4  9    "     7 0 $     )*
  (  "     70

       7   " 1" 8 8 

private void btnPrevious_Click(object sender, System.EventArgs e)
{
currRec--;
if(currRec<0)
currRec=totalRec-1;
FillControls();
}

 9    " 1   8 7    7    7    9     
 0 O   4 9    )*   (  "  0
!9 "    "   "   !;    " 1" 0

6





   


A(  $ 



 7 9        7  1     I     94   9 9  
;  90 %I  9  (7  8   1  0

   7   4 9 9   "  :&: 1   9  1 "   :&": 14 7 
8 7 (0

2(   1  &+O0!        0 Q"   79  (  "(4    
 

 + &(  )F+&(*  (( 7  7   4 "(     0 
7  9   ((    )F *        ( 1@0    
( R%   9 (0  (   (4 9 9  "  
=  )*   79  ;(0

  9    (    0  (  (   7   1
7      ("  0  (   (4 9 9  "   
&)*   79  ;(0

 9 ( 1 1           (( 0    4 "(   U 9  4
"(     (    9 )+9* 7   1 )+ 1* 1@0

6





   




&7   "( 9   2()*  7   (  1 "((   4     1
  (0  "( "  0

  9   &( )*  7   1@           (
10

& 7 ( 9   I  "  ( 7   4 9   8 ( 7   "(   
(( 0

7
 $/((
 
 (( 9 7  8 8 



=  (( 4 9   7      1@ )8 F+&(4 +*  (  
1   9     77  0

public class ADOForm : System.Windows.Forms.Form
{
// Private global members to be used in various methods
private SqlConnection conn;
private SqlDataAdapter dataAdapter;

6'





   



private DataTable dataTable;
private DataSet ds;
private int currRec=0;
private int totalRec=0;
private bool insertSelected;
...

 $ 
 (
'  $0 G  

      7  I% 1I 1"     1   9 8 8 

private void btnLoadTable_Click(object sender, System.EventArgs e)
{
this.Cursor = Cursors.WaitCursor;

string connectionString ="server=P-III; database=programmersheaven;uid=sa; pwd=;";

conn = new SqlConnection(connectionString);


string commandString = "SELECT * from article";
dataAdapter = new SqlDataAdapter(commandString, conn);
ds = new DataSet();
dataAdapter.Fill(ds, "article");

dataTable = ds.Tables["article"];
currRec = 0;
totalRec = dataTable.Rows.Count;

FillControls(); // show current record on the form


InitializeCommands(); // prepare commands
ToggleControls(true); // enable corresponding controls

this.Cursor = Cursors.Default;
}


$      "  $"    7  4       +7"     7 
0 % 9     =  )*  7 7     9  7 0

 
  
 =  )*   8   "     (( 0 =  7    ( 

private void InitializeCommands()
{

66





   



// Preparing Insert SQL Command
dataAdapter.InsertCommand = conn.CreateCommand();
dataAdapter.InsertCommand.CommandText =
"INSERT INTO article " +
"(artId, title, topic, authorId, lines, dateOfPublishing) " +
"VALUES(@artId, @title, @topic, @authorId, @lines, @dateOfPublishing)";
AddParams(dataAdapter.InsertCommand, "artId", "title", "topic",
"authorId", "lines", "dateOfPublishing");

// Preparing Update SQL Command


dataAdapter.UpdateCommand = conn.CreateCommand();
dataAdapter.UpdateCommand.CommandText =
"UPDATE article SET " +
"title = @title, topic = @topic, authorId = @authorId, " +
"lines = @lines, dateOfPublishing = @dateOfPublishing " +
"WHERE artId = @artId";
AddParams(dataAdapter.UpdateCommand, "artId", "title", "topic",
"authorId", "lines", "dateOfPublishing");

// Preparing Delete SQL Command


dataAdapter.DeleteCommand = conn.CreateCommand();
dataAdapter.DeleteCommand.CommandText = "DELETE FROM article WHERE artId = @artId";
AddParams(dataAdapter.DeleteCommand, "artId");
}


 F+&( )  O+1+&(*   (( 7  7  = 4 2(   +
 0  ( 7  ((  F  )  O+1  ( *0 $    
  "     )F  * 1@I  )* 0

$      ; (( 7      (  R% F"    70 
        1          9   "   7  7 9  IPI
 9   (7 7 "  F"0  ;(4 9   9  + I
  ; 

"DELETE FROM article WHERE artId = @artId";

 9   " P=   7   ( "0 = 74  " 9" 1 ( 1  (7 "
9 9   (" 0

6-





   



/&     $ 
&7 7      ; 7   4 9   &)*  1 (    
  7     7   7 "   (   F"0  &)*   
(     7 9  IPI 1     7   0  &)*
  7  

private void AddParams(SqlCommand cmd, params string[] cols)
{
// Adding Hectice parameters in SQL Commands
foreach(string col in cols)
{
cmd.Parameters.Add("@" + col, SqlDbType.Char, 0, col);
}
}


  7       &     ( 7    (  I(  STI

private void AddParams(SqlCommand cmd, params string[] cols)


 ( 89  "    (    9" 8  1 "1 7     
1        II0 =7     8 

AddParams(someCommand, "one");


  7    9" 1  4   7     8 

AddParams(someCommand, "one", "two", "numbers");


  7    9" 1 0 = I  "7"   ; (    H  "J

 I  18   0 $    (   "(( "  (7; 9 IPI  
  7  F  0   ( 7  &)*    ( 7 
(4  7  (    (   " 0

&7 79   1  (4 9   7  77    7   "(0 !9 9  "(
 7  10

$
  
:; $0 ((
 
=  % 1 1"      4 9    )*  7      

private void btnLoadTable_Click(object sender, System.EventArgs e)

6/





   



{
this.Cursor = Cursors.WaitCursor;
...

FillControls(); // show current record on the form


InitializeCommands(); // prepare commands
ToggleControls(true); // enable corresponding controls

this.Cursor = Cursors.Default;
}


$   7    )*   " ((      1   O  ((
7 1"    ; 1;  " 7   (  0

=7   )*    9  7 1 "  9 8  7       7
 9  " "  9 8  7 18   0    7  

private void ToggleControls(bool val)
{
txtArticleTitle.ReadOnly = val;
txtArticleTopic.ReadOnly = val;
txtAuthorId.ReadOnly = val;
txtNumOfLines.ReadOnly = val;
txtDateOfPublishing.ReadOnly = val;

btnLoadTable.Enabled = val;
btnNext.Enabled = val;
btnPrevious.Enabled = val;
btnEditRecord.Enabled = val;
btnInsertRecord.Enabled = val;
btnDeleteRecord.Enabled = val;

btnSave.Enabled = !val;
btnCancel.Enabled = !val;
}

 : A( ;8  


    "  4 9   (     1"   70       7 
1"  "(   (   

private void btnEditRecord_Click(object sender, System.EventArgs e)

63





   



{
ToggleControls(false);
}


      ( 8  7         1 (   7 "  
 )*  (  1 0 $  " (    1" 4  7   4  
8 8



& "   94  ; 1;  1          1"    10 =7  " 9 
     4       1" 4   7  9      4    
  1" 7 8    0

5 3
 0  $*57 
      7    1"   " 7  ; 1;       "   
  10       7    " 

private void btnSave_Click(object sender, System.EventArgs e)
{
lblLabel.Text = "Saving Changes...";
this.Cursor = Cursors.WaitCursor;
DataRow row = dataTable.Rows[currRec];
row.BeginEdit();

6C





   



row["title"] = txtArticleTitle.Text;
row["topic"] = txtArticleTopic.Text;
row["authorId"] = txtAuthorId.Text;
row["lines"] = txtNumOfLines.Text;
row["dateOfPublishing"] = txtDateOfPublishing.Text;
row.EndEdit();
dataAdapter.Update(ds, "article");
ds.AcceptChanges();

ToggleControls(true);
insertSelected = false;
this.Cursor = Cursors.Default;
lblLabel.Text = "Changes Saved";
}

 9 7    ( 1 )1%1* ;  9  "  (       " 
9 "0

lblLabel.Text = "Saving Changes...";
this.Cursor = Cursors.WaitCursor;


 9 8  7    "  I 9      )* 0  "(   9 
"" 1"  1  +9I  )*    )* 0   )*  ( "( 
    7   7 9I 0 $   )*    )* 1" 4 9    
"   ; 1;   90

DataRow row = dataTable.Rows[currRec];
row.BeginEdit();
row["title"] = txtArticleTitle.Text;
row["topic"] = txtArticleTopic.Text;
row["authorId"] = txtAuthorId.Text;
row["lines"] = txtNumOfLines.Text;
row["dateOfPublishing"] = txtDateOfPublishing.Text;
row.EndEdit();


&7         94 9 "(     1 1    2(  7  (0
         ( 7  0       9   1   (
14 9   &( )*  7  + 0

65





   




dataAdapter.Update(ds, "article");
ds.AcceptChanges();


  9 1"       1     )*    (    "
"0 $     1  74    " 18     "(  (
10 )  " 7    1  "      1" I     *

ToggleControls(true);
insertSelected = false;
this.Cursor = Cursors.Default;
lblLabel.Text = "Changes Saved";


=  (         1"  "         "  0 =  1 
7      =   1" 0 =    4  (     " 
4 9    7  =   1" 4  9 9     =     4 
(    9 ( 94    "   (      (     "    
"0
 4  @1 7    1"  1           "   7  ;
1;    14 "(       7  "(   10

5 3
 0  $ 
7 
   1" I      

private void btnCancel_Click(object sender, System.EventArgs e)
{
if(insertSelected)
{
btnDeleteRecord_Click(null, null);
insertSelected = false;
}

FillControls();
ToggleControls(true);
}


 7      1 1"     1 (       =   1" 0
$  =   1"  4  (    (  )9*   1 )  7
9 9 9  *   1   7        1 "    )7*
 0    1"  "    1   7  "      9   0
$       7  9 4  (     "  ) 9  * 9 7
 10 $   "4  " (( 4   1 I I 9    " 9  "

-,





   



  =   1" 0   "  7    1" 9    9  1
   1"  1  =   1" 0
     1"      7 8 9
   "   7  4    + 1" I         "     
  18  70

if(insertSelected)
{
btnDeleteRecord_Click(null, null);
insertSelected = false;
}


 9 7    ); 1;* 7     "     1     18   
0

FillControls();
ToggleControls(true);

  8  
        14  "    =   1" 0 &        1 1
   9 9   + 1I 9  0
        7  =   1" 0

private void btnInsertRecord_Click(object sender, System.EventArgs e)
{
insertSelected = true;
DataRow row = dataTable.NewRow();
dataTable.Rows.Add(row);
totalRec = dataTable.Rows.Count;
currRec = totalRec-1;
row["artId"] = totalRec;

txtArticleId.Text = totalRec.ToString();
txtArticleTitle.Text = "";
txtArticleTopic.Text = "";
txtAuthorId.Text = "";
txtNumOfLines.Text = "";
txtDateOfPublishing.Text = DateTime.Now.Date.ToString();

ToggleControls(false);
}

-





   



 7  9     1  "4       1"    7   
 9  1  =   1" 0 $    9 +9 "   + 1I !99)*
4     9  7   1   "(  "    10

DataRow row = dataTable.NewRow();
dataTable.Rows.Add(row);
totalRec = dataTable.Rows.Count;
currRec = totalRec-1;


!9  9 9       9 "     0
 9     = 7   
"1 7   9  I 9   9  "    ( 8 7 7  10 O7 "   @"
  "0 Q"  9   9 " "     ( 8 7 " 0

row["artId"] = totalRec;
txtArticleId.Text = totalRec.ToString();


$     ; 1;4 1" 7  + 7 "1  ; 1; 9  "      (
 "4   7      1     )* 0

txtArticleTitle.Text = "";
txtArticleTopic.Text = "";
txtAuthorId.Text = "";
txtNumOfLines.Text = "";
txtDateOfPublishing.Text = DateTime.Now.Date.ToString();

ToggleControls(false);

4
 8 
+       (0 & "       7     9     +)*
0  "     2()*  7   (    &( )*  7 
+  (     "      1   ( 10       7 
+  1" 

private void btnDeleteRecord_Click(object sender, System.EventArgs e)
{
DialogResult res = MessageBox.Show(
"Are you sure you want to delete the current record?",
"Confirm Record Deletion", MessageBoxButtons.YesNo);

if(res == DialogResult.Yes)
{

-





   



DataRow row = dataTable.Rows[currRec];
row.Delete();
dataAdapter.Update(ds, "article");
ds.AcceptChanges();
lblLabel.Text = "Record Deleted";
totalRec--;
currRec = totalRec-1;
FillControls();
}
}


       1" 9 (     "  4 9   8  7
7  "  8   "  9    9   0   ("( 9 (   "
9   1; 9 Q   ! 1" 0

DialogResult res = MessageBox.Show(
"Are you sure you want to delete the current record?",
"Confirm Record Deletion", MessageBoxButtons.YesNo
);


=7  "   Q 1"    1;4      "    ;"0

if(res == DialogResult.Yes)
{
DataRow row = dataTable.Rows[currRec];
row.Delete();
dataAdapter.Update(ds, "article");
ds.AcceptChanges();
lblLabel.Text = "Record Deleted";
totalRec--;
currRec = totalRec-1;
FillControls();
}


 9   7    9 (    "      1     +)* 0
$         1   "(     " 10  4 9 7 
  ); 1;* 9      10

  " "   ((  (7    8 "  &+O0!0

-'





   



A *  &   
 7 9   9  R%     " 4 9 ""     0 =  9 " 
;(  " 1  ) *    9  1  0
   7   9 " 
("   7 ( R%  0 &  ("   (( ;"1 1@    
    R%  0

  "  ( " (; R%   9     ("0 &  ("  1
9  (  ("   " "("0

*(
*  &   
$ 9 (   (  (" 9  ( 0  ; "  "  7
9  ("    1 1  (   1          
" 1 1"  " 7 1   &+O0!    0 "  9 (     9 7 7"
1 ( 7  (" 7 % 4 =! 4 2+&    +%  ( 0

= R%  4 "       ("  " 1 "   R%    (
E 0

A&4/*  &  


& (  ("  "(   

CREATE PROCEDURE UpdateProc (
@artId as int,
@title as varchar(100),
@topic as varchar(100),
@authorId as int,
@lines as int,
@dateOfPublishing as datetime)
AS
UPDATE Article SET
title = @title, topic = @topic, authorId = @authorId,
lines = @lines, dateOfPublishing = @dateOfPublishing
WHERE artId = @artId
GO


  7   ("  2(      (" ( 7  7  7 7 " &
10  F"  1 ;" 9   ("  " "(   9  "(( ( 8
)P=* "   "(( (0 =       9   9       
( " ;(   9 "(( "  I     (1  "       7 "   7
9  ("0
-6





   



*8*  &  


& (  ("      

CREATE PROCEDURE InsertProc (
@artId as int,
@title as varchar(100),
@topic as varchar(100),
@authorId as int,
@lines as int,
@dateOfPublishing as datetime)
AS
INSERT INTO article (artId, title, topic, authorId, lines, dateOfPublishing)
VALUES(@artId, @title, @topic, @authorId, @lines, @dateOfPublishing)
GO


  (" 1    =         2( ;(   9 
"   =! R%     7  2+&   0

4*  &  


& (  ("     

CREATE PROCEDURE DeleteProc (@artId as int)
AS
DELETE FROM article WHERE artId = @artId
GO

 9   "     (4      "     ( 8 "0

* *  &  


& (  ("    7  1 

CREATE PROCEDURE SelectProc
AS
SELECT * FROM Article
GO


 (11   ( 7 0 =   8   (         7  &
10

--





   




&  7"  (" (  1   8( ; (       7   
77"  "     " 7  ("    0  9  ("  "
 (;  4 7 "4  "7"  J

A *  &    $/4  


2   (" 9 &+O0!    ; (4 ( 9 9    ( 
(( 9 R%  0 & 9  9   (  R%     ( " 9  
 ("0  ;(   =  )*  7  ( " ;( 9    
  

private void InitializeCommands()
{
// Preparing Insert SQL Command
dataAdapter.InsertCommand = conn.CreateCommand();
dataAdapter.InsertCommand.CommandText =
"INSERT INTO article " +
"(artId, title, topic, authorId, lines, dateOfPublishing) " +
"VALUES(@artId, @title, @topic, @authorId, @lines, @dateOfPublishing)";

AddParams(dataAdapter.InsertCommand, "artId", "title", "topic",


"authorId", "lines", "dateOfPublishing");

000
$ "    ("    9 1 (( 

private void InitializeCommands()
{
// Preparing Insert SQL Command
SqlCommand insertCommand = new SqlCommand("InsertProc", conn);
insertCommand.CommandType = CommandType.StoredProcedure;
dataAdapter.InsertCommand = insertCommand;
AddParams(dataAdapter.InsertCommand, "artId", "title", "topic",
"authorId", "lines", "dateOfPublishing");
insertCommand.UpdatedRowSource = UpdateRowSource.None;
...

 9 7   F  1@     "((     "    7
   (" )=    *       1 "0

SqlCommand insertCommand = new SqlCommand("InsertProc", conn);

-/





   



$      ( (( 7     1@   "  " "0
   "      "     ("0

insertCommand.CommandType = CommandType.StoredProcedure;


  9        ( 1@ "   =   ((0 #" 8  
( " ;( 9     (    0

dataAdapter.InsertCommand = insertCommand;
AddParams(dataAdapter.InsertCommand, "artId", "title", "topic",
"authorId", "lines", "dateOfPublishing");

$0 
D  :; $

  9 "   ("4  7 =  )*  



private void InitializeCommands()
{
// Preparing Select Command
SqlCommand selectCommand = new SqlCommand("SelectProc", conn);
selectCommand.CommandType = CommandType.StoredProcedure;
dataAdapter.SelectCommand = selectCommand;

// Preparing Insert SQL Command


SqlCommand insertCommand = new SqlCommand("InsertProc", conn);
insertCommand.CommandType = CommandType.StoredProcedure;
dataAdapter.InsertCommand = insertCommand;
AddParams(dataAdapter.InsertCommand, "artId", "title", "topic",
"authorId", "lines", "dateOfPublishing");

// Preparing Update SQL Command


SqlCommand updateCommand = new SqlCommand("UpdateProc", conn);
updateCommand.CommandType = CommandType.StoredProcedure;
dataAdapter.UpdateCommand = updateCommand;
AddParams(dataAdapter.UpdateCommand, "artId", "title",
"topic", "authorId", "lines", "dateOfPublishing");

// Preparing Delete SQL Command


SqlCommand deleteCommand = new SqlCommand("DeleteProc", conn);
deleteCommand.CommandType = CommandType.StoredProcedure;
dataAdapter.DeleteCommand= deleteCommand;
AddParams(dataAdapter.DeleteCommand, "artId");

-3





   



}


!  9   "   7   ("    "    F I 1@0 &
  9 9     "        (0       "   
9    % 1 1" I     0

  9  9 "   ("     7  14 9      % 1
1"     0  7  7       

private void btnLoadTable_Click(object sender, System.EventArgs e)
{
this.Cursor = Cursors.WaitCursor;
string connectionString = "server=P-III; database=programmersheaven;uid=sa; pwd=;";

conn = new SqlConnection(connectionString);


dataAdapter = new SqlDataAdapter();
InitializeCommands();
ds = new DataSet();
dataAdapter.Fill(ds, "article");

dataTable = ds.Tables["article"];
currRec = 0;
totalRec = dataTable.Rows.Count;

FillControls();
ToggleControls(true);

this.Cursor = Cursors.Default;
}


 9      9 1 7    1  0 !9 9    
F+&( 1@ "   7" ."   "0   9   (    
   9  "    (" 7    9   (      1@  9 
        7          7  1     (0
         7  =  )*  0 =  9  @" 17 7 
   9       1  ((    =  )* 0

   "       ( " ;( ((  (  R%   9 
("0 = I  (J  ( "  7  ((  1 9  1 8  0


               * 7 
, *+  75 !*+ +    $    

-C





   



  &
  >   $  ',&      
            

        
   *,67&1 
51<& 7191&1+ 1#  ?*+     *54!   /7!  +
-         
       

A 4 ,   


 ?  
+ K       7 9     0!    0 &      (  
0! 1  0$ 900+K 0       (  7  "1 7 
"4 00   14 4  9   0 &     8 8 

/4  /((
 0 4 ,   

%I   ( (( 7   1  7  1        0  7 
         1"  " 7 "   N" " 1;0 $     ! ((
7     I+I    ( ; ((  I
  +1I0   7 
1"  I1 %+I0       7  1" 

private void btnLoadData_Click(object sender, System.EventArgs e)
{
string connectionString = "server=P-III; database=programmersheaven;uid=sa; pwd=;";
SqlConnection conn = new SqlConnection(connectionString);
string cmdString = "SELECT * FROM article";
SqlDataAdapter dataAdapter = new SqlDataAdapter(cmdString, conn);
DataSet ds = new DataSet();
dataAdapter.Fill(ds, "article");

dgDetails.SetDataBinding(ds, "article");
}

-5





   



 9 7    (   7    "  4  9    ( " (( 0   
9     1   7  :: 1      4 9    1   
+  )*  7  +K 0  7 ( 7     4 9   
(    7 1   0

dgDetails.SetDataBinding(ds, "article");


$ " ;"  (     % 1" " 9   "(" (    ( " 7"0

*4  EA 


(
 
  
 
!9 9 9  9 9  "  + K    9 "(  10 $ 9 1 
4      (  1         10   1     ( 8
7  (  1   7 80

 ;(4  " 
  14 1 &"   (  1 7  & 1  
& 1    I&"=I   7 84 9   ( 8   &" 10
=  ;(4 9 9 "     9    7     " 10 =  
(7   ( 19  9 1 9   "  + 

DataRelation relation = new DataRelation("ArtAuth",
ds.Tables["author"].Columns["authorId"],
ds.Tables["article"].Columns["authorId"]);

  7 "  7  +  "    7  9  4 9      
"    "  7  1 9 9 1 "    9 10 &7     (
9          7  0

ds.Relations.Add(relation);

   7  7  % + 1" 



private void btnLoadData_Click(object sender, System.EventArgs e)
{
string connectionString = "server=P-III; database=programmersheaven;uid=sa; pwd=;";
SqlConnection conn = new SqlConnection(connectionString);

string cmdString = "SELECT * FROM article";


SqlDataAdapter dataAdapter = new SqlDataAdapter(cmdString, conn);
DataSet ds = new DataSet();
dataAdapter.Fill(ds, "article");

/,





   


cmdString = "SELECT * FROM author";


dataAdapter = new SqlDataAdapter(cmdString, conn);
dataAdapter.Fill(ds, "author");

DataRelation relation = new DataRelation("ArtAuth",


ds.Tables["author"].Columns["authorId"],
ds.Tables["article"].Columns["authorId"]);
ds.Relations.Add(relation);

DataView dv = new DataView(ds.Tables["author"]);


dgDetails.DataSource = dv;


=  1   9 7 7   9  9 14 7    ( 19    
    0 =   9  4 9      7  +N9  1 "((   ( 
1    "       +" (( 7       90
$ 9 (   ;"  (( 4    9 9   7 (  1 9 IAI 1" 
 7 7  



$ " (  IAI 1"   7 7  4  9 ;(   9   7   (    8

/





   




!9 9 " 8   4    9 9        1



 "    (     ( 7   9 7   10 Q"   18   (  1
"   18 9 1" )_]]*    1 7   0

8 5   $* 


     "   %  4 9  9  79  

private void btnLoadData_Click(object sender, System.EventArgs e)
{
string connString = "server=siraj; database=programmersheaven; uid=sa; pwd=";
SqlConnection conn = new SqlConnection(connString);
string cmdString = "select * from author";
SqlCommand cmd = new SqlCommand(cmdString, conn);

conn.Open();
SqlDataReader reader = cmd.ExecuteReader();

/





   



while(reader.Read())
{
txtData.Text += reader["authorId"].ToString();
txtData.Text += ", ";
txtData.Text += reader["name"].ToString();
txtData.Text += "\r\n";
}
conn.Close();
}

 9     F     F  1@ 1 "   %  0 $ 
(     "   O( )*  7  F  

conn.Open();


&7 (      9   ;"    "   ;")*  7 
F  0   "   1@ 7 ( + 9  1 "     " 
  " 7   F"0

SqlDataReader reader = cmd.ExecuteReader();


 9       1 "    1@0  )*  7  + 
    "   (    ;    "   " " 7   "7"4  9   
    9  0  +       ; ((   1@ 9
8   ) "1* 7  "   "   "   (7 " 7  "  0

while(reader.Read())
{
txtData.Text += reader["authorId"].ToString();
txtData.Text += "\t";
txtData.Text += reader["name"].ToString();
txtData.Text += "\r\n";
}


  9     1   1    )*  7  F  0

conn.Close();


$   9  1          7  % " 7 " 7    "("  ( 
 ;1;  I;+I

/'





   



A( 8   *8+A&4/4 
 (" 7 "(   "  =! 4 2+&    +%          
9 (    ( " ;( ;(        "      "  
    F  1@   ;"! R")*0     7    

private void btnExecuteNonQuery_Click(object sender, System.EventArgs e)
{
string connString = "server=siraj; database=programmersheaven; uid=sa; pwd=";
SqlConnection conn = new SqlConnection(connString);

// Un-comment any one of the following three Queries

// INSERT Query
string cmdString ="INSERT INTO Author " +
"(authorId, name) " +
"VALUES(3, 'Anders Hejlsberg')";

// UPDATE Query
/*string cmdString = "UPDATE Author " +
"SET name = 'Grady Booch' " +
"WHERE authorId = 3";*/

// DELETE Query
/*string cmdString = "DELETE FROM Author " +
"WHERE authorId = 3";*/

SqlCommand cmd = new SqlCommand(cmdString, conn);

conn.Open();
cmd.ExecuteNonQuery();
conn.Close();
}


!     1  9   "  =! 4 2+&    +%         
  9     ;"! R")*  7  F  1@0

/6





   


1
 $ 

 &

 9 9  9    "      0!0 $ 9  " 1 8   9
"     9 9  0 % 9 9   9 9  (  "   " 
(( 0  4 9 9  1"  77  "         9   
0

6$  1
 $ 
E"    7" (  1  (     1 " ((       
;" (    0 $   "  $ 9I "8  14 9 9 "  ;"
    ((    0 #"  9 =  9   6  7  

  I    E7 $4      7     $ &(   9    9  


"  =   +9  E 0 =    4 9  " "   " 77   7 "
(    0 E"   "     7 I (     77" 
7  9 9 ((    I " 0  ;(4 E7 $ 8 "  ("   (   
     9    "  8 (     8     4    
        "  "  "   0 =    4 $ &(
( "    4 ( "        8 "  ("   0   F"
77  7 "8       ((    "( 8    4 9 
"8  77  ((  ;"    0


          
#         &     
   #     *   + 
  
   #      *$+ 
     * + 

/-





   



   79   (

namespace CSharpSchool
{
class Test
{
static void Main()
{
Fun1();
Fun2();
Console.WriteLine("End of Main()");
}

public static void Fun1()


{
for(int i=1; i<=5; i++)
{
Console.WriteLine("Fun1() writes: {0}", i);
}
}
public static void Fun2()
{
for(int i=10; i>=6; i--)
{
Console.WriteLine("Fun2() writes: {0}", i);
}
}
}
}


 "(" 7  ( 

Fun1() writes: 1
Fun1() writes: 2
Fun1() writes: 3
Fun1() writes: 4
Fun1() writes: 5
Fun2() writes: 10
Fun2() writes: 9
Fun2() writes: 8
Fun2() writes: 7
Fun2() writes: 6

//





   



End of Main()
Press any key to continue

& 9  4   " )*     ;" 9 " )*  (  ;" 0  
1" 9    4  ;"    7   4   9   " 
 ;"  7   ;   7      4 004  ( (   
  ;" (0

2  " 4 9  7  "(  "  ;" ( 9 " (  0 
;(4 9  "     9  " )*   " )*  ;" 9" 9  7 
   0

1
 $  
 0! 984   " 4 (  7" "(( 7 "( ;"    (0 Q"  
  7"    " (( 1 "   0   (0 &   0! 
(  1  0  0  0 $   "(   " ( 1  
"(    )1@* 7  0 &    ;" 1    (7   
  9  ;" 7    (0 $  (7       9
 9   1 (    7   (      "0  
0  0   7     9    " (   9 8 
" 0

public delegate void ThreadStart();


 ;(4 9    " ( " ((  "  9   9 77   8 

Thread firstThread = new Thread(new ThreadStart(Fun1));
Thread secondThread = new Thread(new ThreadStart(Fun2));

 9    9    7      (   (     "
9 7     " (0 =  (     7     
 "4 "   4  (      " (0 &    
 ;" 9  1@  0 4 9      ;" 7   1    )*
 7   0

firstThread.Start();
secondThread.Start();

 9     )*  7 7 4 9  " 9   " )*    9 0

9     ;" 9   "   ( 7  " )* 4 1" 9 
  " 9  ;   9    ;" 7 " )*    9 0 & 4  

/3





   



 7 " (( 9  9 7  ( 7  " )*    9   " 9 
79   0  ( "  7  (( 

using System;
using System.Threading;

namespace CSharpSchool
{
class Test
{
static void Main()
{
Thread firstThread = new Thread(new ThreadStart(Fun1));
Thread secondThread = new Thread(new ThreadStart(Fun2));

firstThread.Start();
secondThread.Start();

Console.WriteLine("End of Main()");
}

public static void Fun1()


{
for(int i=1; i<=5; i++)
{
Console.WriteLine("Fun1() writes: {0}", i);
}
}
public static void Fun2()
{
for(int i=10; i>=6; i--)
{
Console.WriteLine("Fun2() writes: {0}", i);
}
}
}
}


O  (1 "(" 7  ( 

End of Main()
Fun1() writes: 1

/C





   



Fun1() writes: 2
Fun1() writes: 3
Fun1() writes: 4
Fun1() writes: 5
Fun2() writes: 10
Fun2() writes: 9
Fun2() writes: 8
Fun2() writes: 7
Fun2() writes: 6
Press any key to continue

$  9  I  (1 "("IH     9  I 1 " 1"  ;" F"  7 
0  9   ( O(   (          " ;" 
(0
 9 9     E )*    17   7   7   9 4 1"
7   9 7"     1     F" 0

$ 9    ;( 9 (   7  9      ; 90  9  I 9
  "("H = 74   " )*   " )*   "  ;"     7   
17  9  7  9  7    0 =7 9    ( "  7  4 9 
    ;" 0

$  
 '
   (   "1 7 "7"    ((         ;" 0

*    0 $*' $ $ 


 
  (( "      7    "  ;"  0 &  (  
1 7      ()* 0 = "  "  ;"    (" ( 7
 (7 "  7 0

 0()*  8   "   "  7  )  * 7 9 9 9   ("
 0  ;(4 9  ("  "  ;"   7    1 (  ,,,   " 
  0()* 0

static void Main()
{
Console.WriteLine("Before Calling the Thread.Sleep() method");
Thread.Sleep(1000); // blocks the currently executing thread (Main thread) for 1 second
Console.WriteLine("After Calling the Thread.Sleep() method");
}

/5





   



$ " ;"  1  (4 " 9    7    19  (   7  9  0

   0 $*' $ $ 


 
    "    1 7    

E1 +(
! & (( 7   ( "  <  7   7     0
 & (( 7 ( 0  0 0  ((  "  <  "
    "  ( 7  0  (  1      7 
  " 9  " &1 !4 9!4 !4
  
%90
=&  &  ((    9        1  0
 & (( 7 ( 0  0 0  ((  "    "
      7  0  " "  1  ((      7 
  " 9  " &14 &1F"4 "( 4 ((4
2 4 "  4 $(# 4 0
)*   ;" 7  0
&1)* &9  "    (  ;" 7   (  0   9 
&1;(   ;"  0
"( )* "  ;" 7   (0
")* "  ;" 7  "(  0
# )* E8  "   9 7     7 0

$ 4  2(
E7 (   
!9 9 9   "    (  7   0    79     (

using System;
using System.Threading;

namespace CSharpSchool
{
class Test
{
static Thread mainThread;
static Thread firstThread;
static Thread secondThread;
static void Main()
{
mainThread = Thread.CurrentThread;
firstThread = new Thread(new ThreadStart(Fun1));

3,





   



secondThread = new Thread(new ThreadStart(Fun2));

mainThread.Name = "Main Thread";


firstThread.Name = "First Thread";
secondThread.Name = "Second Thread";

ThreadsInfo("Main() before starting the threads");

firstThread.Start();
secondThread.Start();

ThreadsInfo("Main() just before exiting the Main()");


}

public static void ThreadsInfo(string location)


{
Console.WriteLine("\r\nIn {0}", location);
Console.WriteLine("Thread Name: {0}, ThreadState: {1}",
mainThread.Name, mainThread.ThreadState);
Console.WriteLine("Thread Name: {0}, ThreadState: {1}",
firstThread.Name, firstThread.ThreadState);
Console.WriteLine("Thread Name: {0}, ThreadState: {1}\r\n",
secondThread.Name, secondThread.ThreadState);
}

public static void Fun1()


{
for(int i=1; i<=5; i++)
{
Console.WriteLine("Fun1() writes: {0}", i);
Thread.Sleep(100);
}
ThreadsInfo("Fun1()");
}

public static void Fun2()


{
for(int i=10; i>=6; i--)
{
Console.WriteLine("Fun2() writes: {0}", i);
Thread.Sleep(125);
}

3





   



ThreadsInfo("Fun2()");
}
}
}


 7  9   7    7  7 ( 0  0   7    
) 4 7     *    E )* 

static Thread mainThread;
static Thread firstThread;
static Thread secondThread;


$   7      = 7)*  (   7 )    * 7  
0  9  " )*   " )*     ( " (   @" (  - "10 = 
( 7   9     ()*  9 9 8   ;"   
"(  7  (7 "  7 0 $     77      I ()* 0
&7  (4 9   (    7 1"     0

public static void Fun2()
{
for(int i=10; i>=6; i--)
{
Console.WriteLine("Fun2() writes: {0}", i);
Thread.Sleep(125);
}
ThreadsInfo("Fun2()");
}


=   E )*  9 7     9     )7      * 1 ( 
   "  7  7  " )*   " )*  (  "    0
$    7    (     ;"   E )*  1 "  
0"   ((   E )* 0

static void Main()
{
mainThread = Thread.CurrentThread;
firstThread = new Thread(new ThreadStart(Fun1));
secondThread = new Thread(new ThreadStart(Fun2));


$    ! (( 7      (   0

mainThread.Name = "Main Thread";

3





   



firstThread.Name = "First Thread";
secondThread.Name = "Second Thread";


&7    4 9 (   "   7    1     = 7)* 4
  9    7    = 7)*  @" 17    7  E )* 0

ThreadsInfo("Main() before starting the threads");

firstThread.Start();
secondThread.Start();

ThreadsInfo("Main() just before exiting the Main()");


O  (1 "(" 7  ( 

In Main() before starting the threads
Thread Name: Main Thread, ThreadState: Running
Thread Name: First Thread, ThreadState: Unstarted
Thread Name: Second Thread, ThreadState: Unstarted

In Main() just before exiting the Main()


Thread Name: Main Thread, ThreadState: Running
Thread Name: First Thread, ThreadState: Unstarted
Thread Name: Second Thread, ThreadState: Unstarted

Fun1() writes: 1
Fun2() writes: 10
Fun1() writes: 2
Fun2() writes: 9
Fun1() writes: 3
Fun2() writes: 8
Fun1() writes: 4
Fun2() writes: 7
Fun1() writes: 5

In Fun1()
Thread Name: Main Thread, ThreadState: Background, Stopped, WaitSleepJoin
Thread Name: First Thread, ThreadState: Running
Thread Name: Second Thread, ThreadState: WaitSleepJoin

Fun2() writes: 6

3'





   


In Fun2()
Thread Name: Main Thread, ThreadState: Background, Stopped, WaitSleepJoin
Thread Name: First Thread, ThreadState: Stopped
Thread Name: Second Thread, ThreadState: Running
Press any key to continue

 (         F"  7 ;"       77  (  "  
;" 7  (0  9  )7      *  I     9  E )*
 9 ; 0 &    7 7 4  E )*   (( 9       
( 0

$ 4  2(
E$ &   '
$ 9     ;"  " "    ( 0 =    4 
(     1"  (  F"     7  (0
9 4 7 9
9   7"  9 (   1"4 9   (7  (   7 " 0 = 0!
9   "   0  0   " 4 9    !4 &1 !4
9!4
   %90  7" (   7   4    I "(4 !0 & 
9   (      1 O(      9  9 (0   
( 19 9  (  

class Test
{
static void Main()
{
Thread firstThread = new Thread(new ThreadStart(Fun1));
Thread secondThread = new Thread(new ThreadStart(Fun2));

firstThread.Name = "First Thread";


secondThread.Name = "Second Thread";

firstThread.Start();
secondThread.Start();
}

public static void Fun1()


{
for(int i=1; i<=10; i++)
{
int t = new Random().Next(20);
for(int j=0; j<t; j++)

36





   



{
new String(new char[] {});
}
Console.WriteLine(Thread.CurrentThread.Name +
": created: " + t.ToString() + " empty strings");
}
}

public static void Fun2()


{
for(int i=20; i>=11; i--)
{
int t = new Random().Next(20);
for(int j=0; j<t; j++)
{
new String(new char[] {});
}
Console.WriteLine(Thread.CurrentThread.Name +
": created: " + t.ToString() + "empty strings");
}
}
}

 9   8  "       "1 7 1@   9   )" )*
  " )**0 O  (1 "(" 7  ( 

First Thread: created: 18 empty strings
First Thread: created: 5 empty strings
First Thread: created: 5 empty strings
First Thread: created: 5 empty strings
First Thread: created: 5 empty strings
First Thread: created: 5 empty strings
First Thread: created: 5 empty strings
First Thread: created: 5 empty strings
First Thread: created: 5 empty strings
First Thread: created: 5 empty strings
Second Thread: created: 16 empty strings
Second Thread: created: 5 empty strings
Second Thread: created: 5 empty strings
Second Thread: created: 5 empty strings
Second Thread: created: 5 empty strings
Second Thread: created: 5 empty strings

3-





   



Second Thread: created: 5 empty strings
Second Thread: created: 5 empty strings
Second Thread: created: 5 empty strings
Second Thread: created: 5 empty strings
Press any key to continue

!9 9 9    ( 7     &1 !

class Test
{
static void Main()
{
Thread firstThread = new Thread(new ThreadStart(Fun1));
Thread secondThread = new Thread(new ThreadStart(Fun2));

firstThread.Name = "First Thread";


secondThread.Name = "Second Thread";

secondThread.Priority = ThreadPriority.AboveNormal;

firstThread.Start();
secondThread.Start();
}

public static void Fun1()


{
for(int i=1; i<=10; i++)
{
int t = new Random().Next(20);
for(int j=0; j<t; j++)
{
new String(new char[] {});
}
Console.WriteLine(Thread.CurrentThread.Name +
": created: " + t.ToString() + " empty strings");
}
}

public static void Fun2()


{
for(int i=20; i>=11; i--)
{

3/





   



int t = new Random().Next(40);
for(int j=0; j<t; j++)
{
new String(new char[] {});
}
Console.WriteLine(Thread.CurrentThread.Name +
": created: " + t.ToString() + " empty strings");
}
}
}

 9    9  0 $      ( 7      &1 !0 $  
      7   "1       9" 1 F"    
"1 7 1@0 O (    ;"   (4 9  "(" 8

Second Thread: created: 14 empty strings
Second Thread: created: 18 empty strings
Second Thread: created: 18 empty strings
Second Thread: created: 18 empty strings
Second Thread: created: 27 empty strings
Second Thread: created: 27 empty strings
Second Thread: created: 27 empty strings
Second Thread: created: 27 empty strings
Second Thread: created: 27 empty strings
Second Thread: created: 27 empty strings
First Thread: created: 13 empty strings
First Thread: created: 13 empty strings
First Thread: created: 13 empty strings
First Thread: created: 13 empty strings
First Thread: created: 13 empty strings
First Thread: created: 13 empty strings
First Thread: created: 13 empty strings
First Thread: created: 13 empty strings
First Thread: created: 13 empty strings
First Thread: created: 13 empty strings
Press any key to continue

   1  "("0 &"         1@4   7  17  7
0   (   9  (   7        7  7 0

33





   



$ 4  2(
E$ 2   

    (   7     ;" 7 77  0 Q"  4 (
) 1*4 "(    " "(   @" 1          1@0
   79    ((

static void Main()
{
Thread firstThread = new Thread(new ThreadStart(Fun1));

firstThread.Start();
Console.WriteLine("Thread started");
Thread.Sleep(150);
firstThread.Suspend();
Console.WriteLine("Thread suspended");
Thread.Sleep(150);
firstThread.Resume();
Console.WriteLine("Thread resumed");
Thread.Sleep(150);
firstThread.Abort();
Console.WriteLine("Thread aborted");
}

public static void Fun1()


{
int i=1;
try
{
for(; i<=20; i++)
{
int t = new Random().Next(20, 50);
Console.WriteLine("Thread 1: slept for: " + t.ToString() + " milliseconds");
Thread.Sleep(t);
}
}
catch(ThreadAbortException ex)
{
Console.WriteLine("Thread 1 aborted in iteration number: {0}", i);
}
}

 9   4 "( 4 "   1   )7 * 9     77  7 -,
 0 1  9    1  "  9  &1;(   
3C





   



0  ;( 9 "   (7   "( 98 17 I   4 00   
(  14 98  7   0 $ 9 ;"  1  (4 9   79  "("

Thread started
Thread 1: slept for: 35 milliseconds
Thread 1: slept for: 29 milliseconds
Thread 1: slept for: 49 milliseconds
Thread 1: slept for: 36 milliseconds
Thread 1: slept for: 33 milliseconds
Thread 1: slept for: 30 milliseconds
Thread suspended
Thread resumed
Thread 1: slept for: 44 milliseconds
Thread 1: slept for: 48 milliseconds
Thread aborted
Press any key to continue

!        19  "(    "0 & 9 7 " =7 "    
"( )*4 ")*  &1)*     ."    )1  " .*4 " 9  
;( 0

A <:;  0   $  


 4 "  8   9 7  "     ( 1    # )* 0  
 ( 

static void Main()
{
Thread firstThread = new Thread(new ThreadStart(Fun1));
Thread secondThread = new Thread(new ThreadStart(Fun2));

firstThread.Start();
secondThread.Start();

Console.WriteLine("Ending Main()");
}

public static void Fun1()


{
for(int i=1; i<=5; i++)
{
Console.WriteLine("Thread 1 writes: {0}", i);

35





   



}
}

public static void Fun2()


{
for(int i=10; i>=5; i--)
{
Console.WriteLine("Thread 2 writes: {0}", i);
}
}


=  1  4   7  E )*  9   F"8 7    9 0  "("
7  ( 9 8 8 

Thread 1 writes: 1
Thread 2 writes: 10
Ending Main()
Thread 1 writes: 2
Thread 1 writes: 3
Thread 1 writes: 4
Thread 1 writes: 5
Thread 2 writes: 9
Thread 2 writes: 8
Thread 2 writes: 7
Thread 2 writes: 6
Thread 2 writes: 5
Press any key to continue

" 7 9 8  8( " E )*    "   7    4 9  (( # )*   0

static void Main()
{
Thread firstThread = new Thread(new ThreadStart(Fun1));
Thread secondThread = new Thread(new ThreadStart(Fun2));

firstThread.Start();
secondThread.Start();

firstThread.Join();
Console.WriteLine("Ending Main()");
}

C,





   



public static void Fun1()
{
for(int i=1; i<=5; i++)
{
Console.WriteLine("Thread 1 writes: {0}", i);
}
}

public static void Fun2()


{
for(int i=15; i>=6; i--)
{
Console.WriteLine("Thread 2 writes: {0}", i);
}
}

 9         # )*  7 7       ( "  7   0
!9  E )*   9    "   7    0 O  (1 "(" 7  (


Thread 1 writes: 1
Thread 1 writes: 2
Thread 1 writes: 3
Thread 1 writes: 4
Thread 1 writes: 5
Ending Main()
Thread 2 writes: 15
Thread 2 writes: 14
Thread 2 writes: 13
Thread 2 writes: 12
Thread 2 writes: 11
Thread 2 writes: 10
Thread 2 writes: 9
Thread 2 writes: 8
Thread 2 writes: 7
Thread 2 writes: 6
Press any key to continue


 5      $   #  = *+
 #    &           
  #   

C





   



$ *'$ D 
 7 9     (  ( 7 "  "( 0 =  7  ( (   74 
 7  ( 9       " )1@*0   9 "     
1 7  (   0 " 9 ((  9 "(       
"H  (1  8    =        0 = 9   9   (
 4   8    9 77    9  9   9   "    
  "0 $    " 4 = 9  (   1"4 " 7" 4     0  8
    9   "  4 1"       0 !9 =   " 7   
        9 77    0 $ 9" 1    "H = 9"     9 
  7        7  8 0  " 9" 1 9   4  9" 1
(    7  9 77   J

  ((  9 "(        " )1@*0   7  1@ 
   "   "    9"  8 9 7  0  "    ( H %I
8     ;(U "((     +9 7  + 1    "(   "
"0 &   4          +9 1@  "(  " "0
       9 18   1   ( 10 " 9  9   1
    1H    "( 1       "( 1  H $  I (  "
" 9    0 =  1    "( 1       "( 1      1  ;"
7 1 7  "(d $ 9 8    "  " H

 9   " H $  ( "    "  1@ 9 "( 0  
"  7" 4 1"   9   ( (0    "   1@ 9 "(
 ;"  " "0 "   4   1  "  1@ 9 "( 0
0! (   8         " "  1 "(     
1@0

$ 91$ 
   79  

class Test
{
static StringBuilder text = new StringBuilder();
static void Main()
{
Thread firstThread = new Thread(new ThreadStart(Fun1));
Thread secondThread = new Thread(new ThreadStart(Fun2));

firstThread.Start();
secondThread.Start();

C





   



firstThread.Join();
secondThread.Join();

Console.WriteLine("Text is:\r\n{0}", text.ToString());


}

public static void Fun1()


{
for(int i=1; i<=20; i++)
{
Thread.Sleep(10);
text.Append(i.ToString() + " ");
}
}

public static void Fun2()


{
for(int i=21; i<=40; i++)
{
Thread.Sleep(2);
text.Append(i.ToString() + " ");
}
}
}


    ((   "1      1" )0 ;0 "* 1@0 & 
"   "("4  7    9" 1   8

Text is:

21 1 22 2 23 3 24 4 25 5 26 6 27 7 28 8 29 9 10 30 31 11
32 12 33 13 34 14 35 15 36 16 37 17 38 18 39 19 40 20

Press any key to continue



 7  ;   "  F"  7 "10      7  9   "4 
 " 8   1@ 17   ((    "1     8 9    0
$  1@  84    " 1 9      7  1@0   ; 9
  8 89 0 $     1  (  (   8  7"  

class Test
{

C'





   



static StringBuilder text = new StringBuilder();
static void Main()
{
Thread firstThread = new Thread(new ThreadStart(Fun1));
Thread secondThread = new Thread(new ThreadStart(Fun2));

firstThread.Start();
secondThread.Start();

firstThread.Join();
secondThread.Join();

Console.WriteLine("Text is:\r\n{0}", text.ToString());


}

public static void Fun1()


{
lock(text)
{
for(int i=1; i<=20; i++)
{
Thread.Sleep(10);
text.Append(i.ToString() + " ");
}
}
}

public static void Fun2()


{
lock(text)
{
for(int i=21; i<=40; i++)
{
Thread.Sleep(2);
text.Append(i.ToString() + " ");
}
}
}
}


!  9    8    1@ I;I 17 98   0
 4  "(" 7  (
9 1

C6





   




Text is:

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40
Press any key to continue

O4


Text is:

21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38
39 40 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
Press any key to continue

Q" 9   7 "(" 9  7  9 "  8  I;I 1@ 7 9    "("
9       "  8   I;I 1@ 70

$  ' 4


9
&  "        80     9  1@ &   0
  7 8 &    

// code for Thread 1
lock(A)
{
lock(B)
{
// do some work
}
}


$     8     &

// code for Thread 2
lock(B)
{
lock(A)
{
// do some work
}

C-





   



}


"((  9         79  ;" F"     1  O( 


  8 8  &
  8 8  
  9 7  8    1  000
  9 7  8  &  1  000

  9     8  & "      8      7   980 O    4
  9     8   "      8  &    7   984 9 9  
(( J
   ( 9 1 8   0
9    8    7 ;  
0  8  7 8  "  1     (  0
 4   " 1 
7" 9 "  "( 80  8  7 1"             
;( 9      (  " U  ( @" ( (  4    "   1
" 0  ;(   8 "74 (   ;"  79  (0

using System;
using System.Threading;
using System.Text;

namespace CSharpSchool
{
class Test
{
static StringBuilder text = new StringBuilder();
static StringBuilder doc = new StringBuilder();
static void Main()
{
Thread firstThread = new Thread(new ThreadStart(Fun1));
Thread secondThread = new Thread(new ThreadStart(Fun2));

firstThread.Start();
secondThread.Start();
}

public static void Fun1()


{
lock(text)
{
Thread.Sleep(10);

C/





   



for(int i=1; i<=20; i++)
{
text.Append(i.ToString() + " ");
}
lock(doc)
{
doc.Append(text.ToString());
for(int i=1; i<=20; i++)
{
doc.Append(i.ToString() + " ");
}
}
}
}
public static void Fun2()
{
lock(doc)
{
Thread.Sleep(10);
for(int i=21; i<=40; i++)
{
doc.Append(i.ToString() + " ");
}
lock(text)
{
text.Append(doc.ToString());
for(int i=21; i<=40; i++)
{
text.Append(i.ToString() + " ");
}
}
}
}
}
}

 9   " 9  1@ );   *0     (   8  9 1@  
(( 0 =7   (" " 4 1   8  7 1@    4  8  1"  
"0 Q"   7    8   7 " 0 "  ;"   (     4 " 9
"  "(    8 " 0 =  4  ( 9     ( (  0

C3





   


#$
*' %*  

 &

 9 9  9 9   ("  $ 9 7    77  ( 7  "    
0!0 $ 9  " 1 8   9 9   (" (  4 7   74   (7
77  (   0 =    7 7   4 9 9 ;(  77  ( 7  " 
0!    9 9    7   9   70   9 9  1"   ( 7
 7 1@   9 9  (    0        "(( 
(  &  " =<O0

6 9 $ $
*' 
   7"      (0 =  7 (4 9 9  9 9    79 
     7 4 00  (   $ 9  7 L    74 "  "
4 (    4 0 =    (4 9 9  9  (7  7 (  "
 ( 4   4  4      0 =   ( 7   4 9 9 ;(  )
*  ("  F"0

  $/((
 K 5  0  L$*' 5  
 
 0       1  "  1  7 1"      7 "
(( 0  ( 7  7  ((     (    79  1

E1 +(
" + K      7 9  ( 9 0
E ! K   7 ("  9  (  "  ;" 0
ON "    7 "  O(  0
2! "   "  7  " ;"   (0
N "   0N 1@ (    (   7 7 
  " "  )%*0
;)*    "  (4 "    ;    O(  0
K)* "   ( ( 7 "   7 7  9 9 (  0
8  74 E " 4  E "   0
K%+ )* "    7 (         7    (    "  0

4  /((
 L5  0  
% 8    ((  "  1     ((     (
     7 0 =   9 9 (( (@       1;  M1; 9  " 
CC





   



(   7 4  1"  M1 K 9 9 1 "   7    7    1"
 M1 ; 9    (( 0     (     K 1" I     

private void btnGo_Click(object sender, System.EventArgs e)
{
OperatingSystem os = Environment.OSVersion;
PlatformID OSid = os.Platform;

string[] drives = Environment.GetLogicalDrives();


string drivesString = "";
foreach(string drive in drives)
{
drivesString += drive + ", ";
}
drivesString = drivesString.TrimEnd(' ', ',');

lbx.Items.Add("Machine Name: \t" + Environment.MachineName);


lbx.Items.Add("Operating System: \t" + Environment.OSVersion);
lbx.Items.Add("Operating System ID:\t" + OSid);
lbx.Items.Add("Current Folder: \t" + Environment.CurrentDirectory);
lbx.Items.Add("CLR Version: \t" + Environment.Version);
lbx.Items.Add("Present Drives: \t" + drivesString);
}

 9   (         7 7 ("1 ((       
   1;0 & 79 (       

    0K%+ )* "    7  4 9    (      0
    0N "   1@ 7 ( 0N 9       7
1"  "   7    " "  )%*0
       7 ; 1" (   ;)*  7          
"  (0

private void btnExit_Click(object sender, System.EventArgs e)
{
Environment.Exit(0);
}

 9   (    ;)* 0  " 9 1 "    O(      1
"  8 9  (   "7"  0 $ = ;"  (   4 =
  79  "

C5





   


  $( $ 05  6 *  0


 L5  , 
 & $:;
     0K)*  1 "    ( ( 7 " 9 9  
7   "   0    "  (      " 7 
0   0(  " 0  7    1 7   " 

E1 +(
  ( 7 7 9 (  ""  0
     7 7  0
+8(+  7 (    8( 7 "0
     7   7   80

 
 7    70
   E +"  70
  7 (      " 7  E "0
     70
       70
E "    " 70
"(  7  "(  "    ^^   "0
   7 7 $ 9 70
&(( +  &(( + 70
 &(( +   &(( + 7
%&(( +  % &(( + 7
8  7 "   8  

% "    ( (  "    7"  0 $  7  ( " ( 
 "  " 1     1 K[8  

private void btnGo_Click(object sender, System.EventArgs e)
{

5,





   



OperatingSystem os = Environment.OSVersion;
PlatformID OSid = os.Platform;
string[] drives = Environment.GetLogicalDrives();
string drivesString = "";
foreach(string drive in drives)
{
drivesString += drive + ", ";
}
drivesString = drivesString.TrimEnd(' ', ',');

lbx.Items.Add("Machine Name: \t" + Environment.MachineName);


lbx.Items.Add("Operating System: \t" + Environment.OSVersion);
lbx.Items.Add("Operating System ID:\t" + OSid);
lbx.Items.Add("Current Folder: \t" + Environment.CurrentDirectory);
lbx.Items.Add("CLR Version: \t" + Environment.Version);
lbx.Items.Add("Present Drives: \t" + drivesString);

lbx.Items.Add("Program Files: \t" +


Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles));
lbx.Items.Add("Common Program Files:\t" +
Environment.GetFolderPath(Environment.SpecialFolder.CommonProgramFiles));
lbx.Items.Add("Windows Desktop: \t" +
Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory));
lbx.Items.Add("Favorites: \t" +
Environment.GetFolderPath(Environment.SpecialFolder.Favorites));
lbx.Items.Add("History: \t" +
Environment.GetFolderPath(Environment.SpecialFolder.History));
lbx.Items.Add("Personal (My Documents:\t" +
Environment.GetFolderPath(Environment.SpecialFolder.Personal));
lbx.Items.Add("Start Menu's Program:\t" +
Environment.GetFolderPath(Environment.SpecialFolder.Programs));
lbx.Items.Add("Recent: \t" +
Environment.GetFolderPath(Environment.SpecialFolder.Recent));
lbx.Items.Add("Send To: \t" +
Environment.GetFolderPath(Environment.SpecialFolder.SendTo));
lbx.Items.Add("Start Menu: \t" +
Environment.GetFolderPath(Environment.SpecialFolder.StartMenu));
lbx.Items.Add("Startup: \t" +
Environment.GetFolderPath(Environment.SpecialFolder.Startup));
lbx.Items.Add("Windows System: \t" +
Environment.GetFolderPath(Environment.SpecialFolder.System));
lbx.Items.Add("Application Data: \t" +

5





   



Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData));
lbx.Items.Add("Common Application:\t" +
Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData));
lbx.Items.Add("Local Application Data:\t" +
Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData));
lbx.Items.Add("Cookies: \t" +
Environment.GetFolderPath(Environment.SpecialFolder.Cookies));
}


$ = ;"  ( 9  1      4 =   79  "

1(
 
  *' 
*' 
0
  
$   (" 7   (7 77  (    "   0=O0  
0=O0= 7 0  0=O0  ;(    (7 " (  
70

O    4  1@ 7 ( 0=O0= 7  (     7 " 9 9  <
77  (( 7  70 % " (    1  

*' 

 
&  9 7   7     (    79  1

E1 +(
()* (  (7 7   (7  (0
)*   (7 70
+)* +  (7 70
5





   



;)* "   "    9  (7 7 ;0
K&1")* "   1@ 7 ( 0=O0&1" 9   77   7
  7 8 9     0
K )* "   1@ 7 ( +   (     7   7 
70
K%& )* "   1@ 7 ( +   (     7     
70
K%$ )* "   1@ 7 ( +   (     7   9  
 70
E )* E   (7 7   (7 (0
O( )* O(   (7 7   "   0=O0 1@ 7  70
O( )* O(   (7 7 7   ("(   "      0=O0
1@ 7  70
O( $)* O(   (7 7 7   ("(   "   <9
0=O0 1@ 7  70
&1")* &(  1@ 7 ( 0=O0&1" 9   77   7
  7     1"   70

E 7  1      79     77"  9  98    (
((    "("0  9 9    7    "    9 9  "  
" (( 0

 0
   :; $
"(( 9 9    7  >.(0;?    7 7   0 $  9  79 
    

File.Create("C:\\c-sharp.txt");


 
 &    
          
5/      $ 

using System.IO;

5'





   


('150
  (':;15:; $ 
!9 7 9 9   (  7   b ( 74 9  "  79   

File.Copy("C:\\c-sharp.txt", "c:\\my programs\\c-sharp.txt");


 "  "  E )*      70 & "  "    7 7  ()*  
)*   8   "    9 " 9   9  7 7  7 9 
  ;    (0 004

File.Copy("C:\\c-sharp.txt", "c:\\my programs\\c-sharp.txt", true);

$9 $2 0 $0


 2 :; $
   1 "  8  ;  7  7

if(!File.Exists("C:\\c-sharp.txt"))
{
File.Create("C:\\c-sharp.txt");
}

, /    00
 , /    :; $
$  8  1" 7  7 "   K&1")* 

FileAttributes attrs = File.GetAttributes("c:\\c-sharp.txt");
lbx.Items.Add("File 'c:\\c-sharp.txt'");
lbx.Items.Add(attrs.ToString());


$ = ;"  (4 =    7       70  "    1"
7  7 1 "   &1"  "

56





   


*' 
0
 
 0=O0= 7    "  (7 77  (   70 2 8   4 9  
  1@ 7  = 7   "   0 &  9 7   (     ((
7  = 7   (    79  1

E1 +(
  K     7  7  70
+ "   += 7 1@  (   (   )7* 7  70
+! "    7  (   )  * 7  70
; "   "    9  (7 7 ;0
;  "   ;  )(* 7  7 )004 0;4 04 0(;*0
"! "   7" (    7  7 )004  b.(0;*0
%&  "   1@ 7 ( +   (     7     
70
%$  "   1@ 7 ( +   (     7   9  
 7
%  "    ) "1 7 1*   70
! "    7  7 )004 .(0;*0
( )* (  7   (7  (0
)*   70
+)* +  70
E  )* E   70
O( )* O(   7 9 " <9     ( 0
O( )* O(   7 7   ("(   "      0=O0 1@
7  70
O( $)* O(   7 7   ("(   "   <9 0=O0 1@
7  70
O( ;)* O(   7   "   0=O0 1@ 9 2 C    
 7  ;  ; 70

/J9 (
2(

&"    1  ((     "  1 @" 1    U 9  
   ( ;(     7"   7  = 7 0 =  79  ;(4 9 9
( (7 77  (    7   (  "    1;  M1;

   
 $
     
   @  
   ;AAB  C    C
< - C
!  9*+  71   
#   

5-





   



$   9  79     MK 1"      

private void btnGo_Click(object sender, System.EventArgs e)
{
FileInfo file = new FileInfo("c:\\c-sharp.txt");
lbx.Items.Add("File Name: " + file.Name);
lbx.Items.Add("File Extention: " + file.Extension);
lbx.Items.Add("File's Full Name: " + file.FullName);
lbx.Items.Add("Parent Directory: " + file.DirectoryName);
lbx.Items.Add("File Size: " + file.Length.ToString() + " bytes");
lbx.Items.Add("File Attributes: " + file.Attributes.ToString());
}

 9   ( "  (( 7  = 7       (    7 1"  70
$ = ;"  (   4 =   79  "("



! 7 ;"   (4 =    1" 7 7 M b.(0;   4
  
&  "  $ 9 ;(0

1(
 4    :0
 ; *' 4   '*' 4   '0

  
      = 7  9  (7   (    "   +  
+= 7 0 &   9.     0=O0+       9
 0=O0+= 7        1  (7 " 8  0

5/





   



*' 4   '


 
&  9 7   7  +   (    79  1

E1 +(
+)*   (7 0
+)* +  (7 0
;)* "   "    9  (7  ;0
K )* "   1@ 7 ( +   (     7   7 
(7 0
K+)* "    7         7   "1. 7 
(7 0
K)* "    7         7   7      (7
0
K )* "    7         7   7      
  (7 0
K )* "   1@ 7 ( += 7 (    (   7  (7
0
E )* E   (7         )7   *   (7
(0

 +
 $90  $2 0    
     9  (7  1  (   9 190

private void btnGo_Click(object sender, System.EventArgs e)
{
lbx.Items.Add("Directory 'C:\\Faraz' exists: " + Directory.Exists("C:\\Faraz"));
lbx.Items.Add("Creating Directory 'C:\\Faraz': " + Directory.CreateDirectory("C:\\Faraz"));
lbx.Items.Add("Directory 'C:\\Faraz' exists: " + Directory.Exists("C:\\Faraz"));
lbx.Items.Add("Parent Directory of 'Faraz' is: " + Directory.GetParent("C:\\Faraz"));
lbx.Items.Add("Deleting Directory 'C:\\Faraz'... ");
Directory.Delete("C:\\Faraz", true);
lbx.Items.Add("Directory 'C:\\Faraz' exists: " + Directory.Exists("C:\\Faraz"));
}


& 4   (   "   7  +   (7  ( 0 O 
       9   (  (.     " "   +0+)* 0  
 " "     (   "      )%*      "  00
     7    1"    7         "1.  
  0
53





   



,  $  :0


   E    ;0   '
 +  ;(          7  0 +0K+)*
"    7   "1. 7  (7 4 +0K)* "    7   7 
 (7    +0K )* "    7   7   "1.
     (7 0 %    7     7  $ 9 7 7 " 0

private void btnGo_Click(object sender, System.EventArgs e)
{
// get the path of Windows Folder's System Folder
string winFolder = Environment.GetFolderPath(Environment.SpecialFolder.System);
// Separate the Windows Folder
winFolder = winFolder.Substring(0, winFolder.LastIndexOf('\\'));

string[] fileSystemEntries = Directory.GetFileSystemEntries(winFolder);


string[] files = Directory.GetFiles(winFolder);
string[] directories = Directory.GetDirectories(winFolder);

// show windows folder path


lbx.Items.Add("Address of Windows Folder: " + winFolder);

// show files/folder in windows folder


lbx.Items.Add("");
lbx.Items.Add("File System Entries (files/folder) in the Windows Folder: ");
foreach(string fileSystemEntry in fileSystemEntries)
{
lbx.Items.Add("\t" + fileSystemEntry);
}

// show files in windows folder


lbx.Items.Add("");
lbx.Items.Add("Files in the Windows Folder: ");
foreach(string file in files)
{
lbx.Items.Add("\t" + file);
}

// show folder in windows folder


lbx.Items.Add("");
lbx.Items.Add("Directories in the Windows Folder: ");
foreach(string directory in directories)

5C





   



{
lbx.Items.Add("\t" + directory);
}
}


&  9 = ;"  1  (   4 =   79  "

*' 4   '0


 
 0=O0+= 7    "  (7 77  (   0 2 8  +
4 9     1@ 7  += 7   "   0 &  9 7  7  ( 
   (( 7  += 7   (    79  1

E1 +(
; "    "    9  (7  ;0
;  "   ;  )(* 7  0
"! "   7" (    7   )004  b*0
! "    7   )004 *0
  "   7" (    7  (   7  0
)*    9  (7 0
55





   



+)* +   9  (7 0
K+)* "    7 ( += 7  (    "1. 7 
0
K)* "    7 ( = 7  (    7      0
K= 7)* "    7 ( = 7  (    7   7
     0
E  )* E           )7   *   (7 (0
7)* 7     7 += 70

4  ((
 0  $4   '0
 

 9      ( " ;(    9 "  += 7    7  +
0  "(" 7  ( 9      7  ( "  0  7  

private void btnGo_Click(object sender, System.EventArgs e)
{
// get the path of Windows Folder's System Folder
string winFolder = Environment.GetFolderPath(Environment.SpecialFolder.System);
// Separate the Windows Folder
winFolder = winFolder.Substring(0, winFolder.LastIndexOf('\\'));

DirectoryInfo winFolderObj = new DirectoryInfo(winFolder);


FileSystemInfo[] fileSystemInfos = winFolderObj.GetFileSystemInfos();
FileInfo[] fileInfos = winFolderObj.GetFiles();
DirectoryInfo[] directoryInfos = winFolderObj.GetDirectories();

// show windows folder path


lbx.Items.Add("Address of Windows Folder: " + winFolderObj.FullName);

// show files/folder in windows folder


lbx.Items.Add("");
lbx.Items.Add("File System Entries (files/folder) in the Windows Folder: ");
foreach(FileSystemInfo fileSystemInfo in fileSystemInfos)
{
lbx.Items.Add("\t" + fileSystemInfo.FullName);
}

// show files in windows folder


lbx.Items.Add("");
lbx.Items.Add("Files in the Windows Folder: ");
foreach(FileInfo fileInfo in fileInfos)
{

',,





   



lbx.Items.Add("\t" + fileInfo.FullName);
}

// show folder in windows folder


lbx.Items.Add("");
lbx.Items.Add("Directories in the Windows Folder: ");
foreach(DirectoryInfo directoryInfo in directoryInfos)
{
lbx.Items.Add("\t" + directoryInfo.FullName);
}
}


& "    4    77  19     ( "     9  "  
+= 7 1@    ((   7  + I  0 &  " 7 
( 9 1    7  ( "  4 (     7 7<7   $ 9 70

  "    9     79    (7 77  (   7   7   
  7 1" 7     ((       0!0 O   9 7 "   "
" 1  7" 9  ("  7     " (( 0 =  ;(    4 9
   (     ;(   1 9 1" 7  1  7 (7 7   
(  7 77  70 =  9 1 (  9  7    000 180

*  
=  (   ;4 " 7   7  ;0   M&    1@ "    
9     7   " )004 7 4 984  4 *0   M&   
1 7  F"  7 14 8  70 = (            9  U   
    " 9         9 7  0   "  1 
74         0

$ "  4 E    !98   <9     7   "0

 4  1 7"   7      9   1  7   9    "0

  

3-
6

( &
 (.; :8*
9:5 &
 (1 % - $
.4 78*
97
,-
7:3
    5 

',





   



/5 50 $00   '( 0  
    77   "0 +  1  7 7    84    4   
7   =<O  0 &  ( 9   (   7    7    
" "  (  8 )*   $)*0

$   9       9   4 "  9   "     9    
       "4    9 70  (  ;  7"0 + ! )0!* ( 
77       77  ( 7 0  1  7      0! 798 
0=O00 =7 " 9       7 "  " 0=O04 7 " 9   
  4 "  " 0=O0E4   7 " 9        4 "  "
0!080!980

 1   1"   "  0!   "     9 1" 9   " 
7   7 4 98 8  U  "           1@ 1
7     "          ( )*   $)* 0

$   1 "   0$% )*    0% )*   7  0 = 74 
0   (    ("4 "("         9 90     $)*
     4 9      )1*     9 90

$*' * 


 L $  0

   $ 0  9


 0   1  9      0! 798  0 = ;( 
((      1      )8 4 !984 *0

&  9 7  7      ((     (    79  1

E1 +(
  "    "    9     7   "0
 $ "    "    9    9    "0
%  "      "1 7 1   "  0
 K<  "  ( 7  0 &  <9 (    
 "   "  ( 0
)*   0
")* $        1"77    "0
8)*   "  ( 7  0
)1ST 1"774     (7 "1 7 1 7  "  ( 7     
774   " * "((  7 1   "   "1 7 1 "  7  0
)" (  *
)*     1 7  "  ( 7     "   1 
    0  M. " "      7   7 0

',





   



$)1ST 1"774   $  (7 "1 7 1   "  ( 7   7 
774   " * "((  7 10
)" ( *
$)* $    1   "  ( 7  0

400   '( 00


  L86   0
 
 @ ( 7    1" 7 4 9  "   7   9  70  
"    0! 798   1 "     9 70 Q"  ( "
0=O0  <9 1   70 &   "  "  0=O0   
0=O0 $    1    (   (0 &  "   " 
0=O0   0=O0$   <9 ; 70 $ 9   
7    1  0

A *' 
*       0
 
 0=O0     0=O0   (    7"    
  9   70 = (   7  1 1 7     98 9 70 7
"    7   ( 4 9   "  0=O (  " (@

using System;
using System.IO;


$           77  90 $  "   7  0O( )*4
0O( )*   0O( $)*  7  0=O0 0

FileStream fs = File.Open("C:\\C-sharp.txt", FileMode.Open);


Q"   "  = 7  O( )*4 O( )*   O( $)* 0

FileInfo objFileInfo = new FileInfo("C:\\C-sharp.txt");
FileStream fs = objFileInfo.Open(FileMode.Open);


  "  "   7  "1 7    " 7   0 $     7
4 9  7  7" (0

/  (    $( $0 $0


 
& E  "     7  9  (   " (  70  (1 "
 " O( 4 O( O4 &(( 4    0 =7 E  O( 4  9 (  (  ; 
70 =7 E  O(   9 (  (  ;  7U 7  7 ;4  9   9  0
= &((  7 4  9  9 1 9     7  ;  70

','





   




& &  "    7  9 (   9 "   7 0  (1
"  " 4 $   $0 =7 &  4 "     7  7 0

&   "     7     (  7  70  (1 "  " ! 4
4 $4 $0 =7   ! 4     (  7 "  "     
( 0 =7   4    (      7  70

( 0 0



!9 9I     ( 7   7 7 4 I    (0 = (4     7
          0 %   9 9 ((    7    ; 1;4 9
 "     ;      18   70  (( 9 7  8 8 



  1     (0       7    1" )1 K* 

private void btnGo_Click(object sender, System.EventArgs e)
{
string fileName = "C:\\C-sharp.txt";
lblFileName.Text = "File Name: " + fileName;

',6





   


// Open existing file in Read only mode without allowing any sharing
FileStream fs = new FileStream(fileName, FileMode.Open, FileAccess.Read, FileShare.None);

// create an array of bytes of the size of file\


// and read file contents to it.
byte[] byteText = new byte[fs.Length];
fs.Read(byteText, 0, byteText.Length);

// convert bytes array to string and display in the text box


txtFileText.Text = System.Text.Encoding.ASCII.GetString(byteText);

// close the file stream so that other streams may use it


fs.Close();
}

4 9   "  7   (  ;  7 )E0O( *      )&0*
  9" 9       "  9 " ((  "   7 )0! *0 $ 
   7 1 9   F"     7  7     7   0

fs.Read(byteText, 0, byteText.Length);

 9   (7  9 9     7       1 ; 4   7  "
 7    7  M,  ;     "  1 ;0%  ) 7 7* 1 7  70
&7      4 9      1          1 (   ; 1;0
 4 9      )  "  7*       0

4       7    1" )1  * 

private void btnSaveFile_Click(object sender, System.EventArgs e)
{
string fileName = "C:\\C-sharp.txt";

// Open existing file in Read only mode without allowing any sharing
FileStream fs = new FileStream(fileName, FileMode.Open, FileAccess.Write, FileShare.None);

// covert the text (string) in the text box to bytes array


// and make the byteText reference to point to that byte array
byte[] byteText = System.Text.Encoding.ASCII.GetBytes(txtFileText.Text);

// write the byte array to file from the start to end


fs.Write(byteText, 0, byteText.Length);

',-





   


// close the file stream so that other streams may use it


fs.Close();
}

 9   7    ;   ; 1;   1     9    7 "  
 $)* 

fs.Write(byteText, 0, byteText.Length);


=  1    9        9  1   1 ;     70
$   8    9  7  7 1 7     9  (    70

A 7 '8 7 '6       (  5  0


 
 (1 9 "       9       9 1   70 $   
;(    ( 7  ) 4 "14 14  *  1 17 9    7 )    7
 *0  + ! )0!* 798  1 (  9   9 "     9 ( 
 (   70 $  " 0=O0    (   ( 7  7  
0=O0 $  9 (    70

& (  (  1"       $         1 ( 
  "0   "       9 ( 0

%   ((  9 77  (    7      180
 (( 9 7  8 8 

',/





   




 ; 1;   ((    0 & 74    1"   1    "  
     1"     7 74      7 18   ; 1;0     9 
 7         1"  8      9 

private void btnSaveFile_Click(object sender, System.EventArgs e)
{
string fileName = "C:\\C-sharp.txt";

// Open existing file in Read only mode without allowing any sharing
FileStream fs = new FileStream(fileName, FileMode.Open, FileAccess.Write, FileShare.None);

// Open the Writer over this file stream


BinaryWriter writer = new BinaryWriter(fs);

// write different types of primitives to the file


writer.Write("I am Fraz\r\n");
writer.Write("Age: ");
writer.Write(23);
writer.Write("\r\nWeight: ");
writer.Write(45.5);

// close the file stream so that other streams may use it


writer.Close();
fs.Close();

btnLoadFile.Enabled = true;
}

 9   7   7    "        $ 0 $    9
77  (     "   $ $)* 4 9        
9 77  ( 7 ( 0   9     9     1  %  1" 0
      7  %  1" 

private void btnGo_Click(object sender, System.EventArgs e)
{
string fileName = "C:\\C-sharp.txt";
lblFileName.Text = "File Name: " + fileName;

// Open existing file in Read only mode without allowing any sharing
FileStream fs = new FileStream(fileName, FileMode.Open, FileAccess.Read, FileShare.None);

',3





   



// Open the Reader over this file stream
BinaryReader reader = new BinaryReader(fs);

// read different types of primitives to the file


string name = reader.ReadString();
string ageString = reader.ReadString();
int age = reader.ReadInt32();
string wtString = reader.ReadString();
double weight = reader.ReadDouble();

// concatenate primitives into single string and display in the text box
txtFileText.Text = name + ageString + age.ToString() + wtString + weight.ToString();

// close the file stream so that other streams may use it


reader.Close();
fs.Close();
}

 9      1@ "    1@0 $    (  ( "
9   70 &7     4 9     (          (   
; 1;0   9   9 0  (  (        (     
   9 9 0

A * 8 * 6        2 0


 
     $  "     9 ; 70     "7" 
8 % )*     )*  7      9  7 ; 70 E  4  
 " 77  ;    )8 &==   2 * 7     9   70

 
 = 
   
C         & 
 
   
      D  D  

&
          

    
        =       
   
57

O   4 = 9 "      ( 9" ( @" 1"  8 (   0 Q" "
(   " (  9 "  7 1 "   0

',C





   



* 
D 4E  
D 
   ( 7 9  1@    9 +.   ( 7   1@
7  0 2( "  94 9    9  <9 (  (    1" 9   
<9   ;( )" 7 * (   0    (   " 1  17
" (     0

 ("( 7    9   1@         0   7  1@   
1     10
     1@   9   7  1 )   * 1 )
  1@ (*   0 E   1     9   0

Q"    1@ "7 1 ( 9   7  1 1   0 $
. 4 " 9"       1 1    F"   9  9 9 0

9   ( 7     .   9 @   

 =   " @1  9   1 1 "7     1  7 " 
     7 1   7 "      " 7  1@0
 =      ("0  ( 9  9   .  1@ " 
( "4 9"    1 9 7  F"   9 " 9  1 1   "
79  F" 0

 + )0!* 798 8  7  "   (  1    O& 7 "  9 "
  " 1@ @" 1    )*   +)* 0

   " " "   9  0 Q"   9     1  
   "   9     7 " 1 1   0  ;(4 
91.((   9  2= 7 1@  1    9 7  1 0
&    0!  " .1 1 7" .      1 9   0 Q"   
;( 8 "   1 1 "   S1T 1"0

Q"  (  8  (" 1 1 ) 7*  ! . 1 "   S! T
1"  (    % 7 9   7 9    1@0

 
 
C
  !"5    !"
   
 #    *$        +&
   4         
 57
 

(
 * 
D 4  
D L/ (
2(

%     ((      1 0  (( 9   1@   7
      7  7    1@0 $ 9 "  (   "  " 7
9   10  ( "  7  ( 
',5





   




using System;
using System.IO; // for FileStream
using System.Runtime.Serialization.Formatters.Binary; // for BinaryFormatter

namespace Compiler
{
class Test
{
static void Main()
{
Addition addition = new Addition(3, 4);

FileStream fs = new FileStream(@"C:\C-Sharp.txt", FileMode.Create);


BinaryFormatter binForm = new BinaryFormatter();

Console.WriteLine("Serializing the object....");


binForm.Serialize(fs, addition);

fs.Position = 0; // move to the start of file

Console.WriteLine("DeSerializing the object....");


Addition sum = (Addition) binForm.Deserialize(fs);

int res = sum.Add();


Console.WriteLine("The sum of 3 and 4 is: {0}", res);
}
}

[Serializable]
class Addition
{
private int num1;
private int num2;
private int result;

public Addition()
{
}

public Addition(int num1, int num2)


{

',





   



this.num1 = num1;
this.num2 = num2;
}

public int Add()


{
result = num1 + num2;
return result;
}

public int Result


{
get { return result; }
}
}
}


 &    (     (  10 !  9   8   9 
S1T 1"0 &   9    " ((( (0

using System;
Uusing System.IO; // for FileStream
using System.Runtime.Serialization.Formatters.Binary; // for BinaryFormatter


=  E )*  9        7  & 0 $      7   
  1@   7 "      )$ 9  
     
 *0

FileStream fs = new FileStream(@"C:\C-Sharp.txt", FileMode.Create);
BinaryFormatter binForm = new BinaryFormatter();

Console.WriteLine("Serializing the object....");


binForm.Serialize(fs, addition);


   9     " ( 9    1@0 +     1" 17
  9     7 (  (    7  7

fs.Position = 0; // move to the start of file


!9 9    1@ 7   "        

'





   



Console.WriteLine("DeSerializing the object....");
Addition sum = (Addition) binForm.Deserialize(fs);


    +)*  8  7    (4   1@ ( 7
   "   1@ 7 ( 0O1@0 $    ;(      0 O  9   
 1@4 9   &)*  7   9 "  (  1 7    ("  "
  (   "    

int res = sum.Add();
Console.WriteLine("The sum of 3 and 4 is: {0}", res);


$ " (   ;"  (4 " 9   79  "("


Serializing the object....
DeSerializing the object....
The sum of 3 and 4 is: 7
Press any key to continue

=7 "   @"  S1T 1"    &  7  4 " 9   ;( 9
)*  7     0  J

// [Serializable]
class Addition
{
...

   * 
D 
& 7 1  7  9  1@  0  7 " 1     1 
      ( " "     (1 70 = 0!4  7  
(   0" 0 0=  70  9  7    
 )0" 0 00 0 *    O& 
)0" 0 00(0(*0  O& )( O1@ & *  
  (            "(( 7 E74 =E     "  0   
   ( 7   0

& 5  


 0 * 
DL$M* 
DN   
Q"  (    % 7    7 9    1@0   1 77   
7 0 Q"     7 " ("(  7 " 9     8 ( 1  9    

'





   



   70   " (   8  7 9  S! T 1"0  ;(4  "
   " 7  S! T0  ( "  7  7 ( 

using System;
using System.IO; // for FileStream
using System.Runtime.Serialization.Formatters.Binary; // for BinaryFormatter

namespace Compiler
{
class Test
{
static void Main()
{
Addition addition = new Addition(3, 4);
addition.Add();
Console.WriteLine("The value of result is: {0}", addition.Result);

FileStream fs = new FileStream(@"C:\C-Sharp.txt", FileMode.Create);


BinaryFormatter binForm = new BinaryFormatter();

Console.WriteLine("Serializing the object....");


binForm.Serialize(fs, addition);

fs.Position = 0; // move to the start of file

Console.WriteLine("DeSerializing the object....");


Addition sum = (Addition) binForm.Deserialize(fs);

Console.WriteLine("The value of result is: {0}", sum.Result);

Console.WriteLine("The sum of addition is: {0}", sum.Add());


}
}

[Serializable]
class Addition
{
private int num1;
private int num2;
[NonSerialized]
private int result;

''





   



public Addition()
{
}

public Addition(int num1, int num2)


{
this.num1 = num1;
this.num2 = num2;
}

public int Add()


{
result = num1 + num2;
return result;
}

public int Result


{
get { return result; }
}
}
}


!  S! T 1"    " 70 !9    E )*  7  (0 $ 7
     7  &  9 9 "14   &)*   ("  "   (  0

Addition addition = new Addition(3, 4);
addition.Add();
Console.WriteLine("The value of result is: {0}", addition.Result);


$    1@     18    1@4 @" 8   ( " ;(

FileStream fs = new FileStream(@"C:\C-Sharp.txt", FileMode.Create);
BinaryFormatter binForm = new BinaryFormatter();

Console.WriteLine("Serializing the object....");


binForm.Serialize(fs, addition);

fs.Position = 0; // move to the start of file

Console.WriteLine("DeSerializing the object....");

'6





   



Addition sum = (Addition) binForm.Deserialize(fs);


!9    ; (0  9 (   " 7  " 1 "   " ((0

Console.WriteLine("The value of result is: {0}", sum.Result);


=7  " 7 "   4  1    " (  0   9 (   " 7  

Console.WriteLine("The sum of addition is: {0}", sum.Add());


 1    " (   " 7 '   6 7  1 "   " 9 0 $ 9 (
  ;"  (4 9   79  "0

The value of result is: 7
Serializing the object....
DeSerializing the object....
The value of result is: 0
The sum of addition is: 7
Press any key to continue.

=  "("4 9     " 7  " 7 7   4 "    7 "
   9  1@0  " 7 " )'A6]3* 7    &)*  "   7
"   "    9  1@0
 4 9  (    7 " 7 7   9
 1@0

,  0$4  
DE $4  
D  

79  0
$ 9   9   7 " 7   9  1@4 9  8  (7  98  
1@ 9     9  ((  . 70  ;(4 9  8  (" 
" 1 7  &  9    1@0  4 9   (  
=+ 8  70   7        

void OnDeserialization(object sender);


   9    (    9  1@  0 %I    ( "
((   " 1    "   7    0  7 "  

using System;
using System.IO; // for FileStream
using System.Runtime.Serialization; // for IDeserializationCallBack
using System.Runtime.Serialization.Formatters.Binary; // for BinaryFormatter
namespace Compiler

'-





   



{
class Test
{
static void Main()
{
Addition addition = new Addition(3, 4);
addition.Add();
Console.WriteLine("The value of result is: {0}", addition.Result);

FileStream fs = new FileStream(@"C:\C-Sharp.txt", FileMode.Create);


BinaryFormatter binForm = new BinaryFormatter();

Console.WriteLine("Serializing the object....");


binForm.Serialize(fs, addition);

fs.Position = 0; // move to the start of file

Console.WriteLine("DeSerializing the object....");


Addition sum = (Addition) binForm.Deserialize(fs);

Console.WriteLine("The value of result is: {0}", sum.Result);


}
}

[Serializable]
class Addition : IDeserializationCallback
{
private int num1;
private int num2;
[NonSerialized]
private int result;

public Addition()
{
}

public Addition(int num1, int num2)


{
this.num1 = num1;
this.num2 = num2;
}

'/





   


public int Add()


{
result = num1 + num2;
return result;
}

public int Result


{
get { return result; }
}
public void OnDeserialization(object sender)
{
result = num1 + num2;
}
}
}


!      &    =+ 18  7   (   7  7
 O +   9  ("  " 7 "   "       " 7

public void OnDeserialization(object sender)
{
result = num1 + num2;
}


 E )*           ( " ( 1"   9 "     "
  " 7 7  7  O +   0 $ 9 (   ;" 
1  (4 9   79  "


The value of result is: 7
Serializing the object....
DeSerializing the object....
The value of result is: 7
Press any key to continue

 " 9   O + )*   "  9   (7  9
     " 7  " 7 7  0

'3





   



/ '$  86   $*  
2( "  9 9     "   "     9   0 !9 9 9    "
    9   0  7 1 " F"  9   "     " <9
 H #"   " ( " (" 7     9    0 $ "    )*  
$)* 0  ;(4 9   )* 1 (7   "  7   1   
"(( 0

byte[] byteText = new byte[fs.Length];
fs.Read(byteText, 0, byteText.Length);
SomeOtherMethod();


$ 9   )* 4 " ( )  "  *  18 "     1   
"((    OE)*     9  (   1     0  
    " 4 00 9  " 9      0     ((  9 $)*4
        " 90 =    "    9 9 @" "      
9 "  0=O0 I  )*    $)* 0 O  9   )* 
 $)*4 9    " "

  "    ;"     79    )*   $)* 9"
9  7    9  1 (0
   % " "  )%*     9       7 " ( 9
  (0

  8 J " 9   %  7 " (     9  1 (H $
  " (   9 (    "  4 1    4   &  "
=<O0    )*    $)*  8   7 ( 0& 180  
& 18  7     ( 

public delegate void AsyncCallback(IAsyncResult ar)


      & 18  7         " (   8 
( 7 ( 0=& "0  ( =& "  1 "  "((  7 1" 
  " ( 0 E 7  4 9   1 1"  1@0 & (   
& 18   7  

public void OnWriteCompletion(IAsyncResult ar)
{
Console.WriteLine("Write Operation Completed");
}

'C





   



/  ((
 
% 9   (   ((     " 7 &  " <9  0
 <9 (    (( 9 1   "0  "  7  ( 

using System;
using System.IO;
using System.Threading;

namespace CSharpSchool
{
class Test
{
static void Main()
{
FileStream fs = new FileStream(@"C:\C-Sharp.txt", FileMode.Open);
byte[] fileData = new byte[fs.Length];

Console.WriteLine("Reading file...");
fs.Read(fileData, 0, fileData.Length);

fs.Position = 0;
AsyncCallback callbackMethod = new AsyncCallback(OnWriteCompletion);
fs.BeginWrite(fileData, 0, fileData.Length, callbackMethod, null);

Console.WriteLine("Write command issued");


for(int i=0; i<10; i++)
{
Console.WriteLine("Count Reaches: {0}", i);
Thread.Sleep(10);
}
fs.Close();
}
static void OnWriteCompletion(IAsyncResult ar)
{
Console.WriteLine("Write Operation Completed...");
}
}
}


=  1   184 9   7       M18E 7 ( & 18  
E )*      7   O $( )* 0 $     7 4  
   M7+      7 (  (    7  70
'5





   




$     9    7 "    $)* 4 (     1  M7+
      18  MO $( )*0

AsyncCallback callbackMethod = new AsyncCallback(OnWriteCompletion);
fs.BeginWrite(fileData, 0, fileData.Length, callbackMethod, null);

$    (  "1   (  "    7 ,      0   9  
  0   9      $)*   9     7  74   
 "  18   9   9   (4  "   "   (   "1   (0
$ 9    7  (4  O $( )*  "  4 (     
  0   ("(4 = (   ;      M.(0; 7   ;"  (
   79  "


Reading file...
Write command issued
Count Reaches: 0
Count Reaches: 1
Count Reaches: 2
Write Operation Completed...
Count Reaches: 3
Count Reaches: 4
Count Reaches: 5
Count Reaches: 6
Count Reaches: 7
Count Reaches: 8
Count Reaches: 9
Press any key to continue

 "     "("  7 "   9  4        184
1"   "  (   "10 O   9 ( 9 (4  (    9  (
  "  0

  8 / '$  8I6  


$ "    " <94  " " 1  

 &  " <9    7 =<O 8  8        (0 =  
 8  "   " (  7     9   70     9  
"     7   1    0
 =  18" 4  )*    $)*   (     
 <9  8   9 0
  "   (  " 9  )*  

',





   



 $)* 4 7 ;(4 7     $      
 0

(  (    $ 0*  


  (    9 " 1 8(    9        ; (  
   " ( 0 =7 "     4  7 (  1 " ( 9  1
1     ( "  " ((  0  ( 7 1"     1"0
=  9   (  (  7     000 18   7 (7      1
 1 "   ;" 7  0

=  9   8       7  18    9 "      7 
18 9 1 ;"  7  (  7 ;( 0  9 " 9" 1  "   ( 
 9" 1 0

'





   


"    

5
5 
   (   7   18 " 98 9 1  7       7    "
   "   0! 7980  ( 8   @    9      
7 4 8 9   0,0

E"    9   9 7"    "4 (" 9   9 77  9  
 ;  (0 2"   1    189 (1 9 ( 9  ( "
  7   "0  0,   "( 7  0,4     ( 9   0, " 
(   "  ;( 9  0,    0, 7  0! " 0   4 9 4   "0
  0, (   1 ;(  ( 9   0, (4 1" "  ;(  
( 0! 1  "   7  7  %0      B      1
   "   4 7     9 1 ;( 0     7 " 94 (  
1"  0, (4 " " 9         7  0! "   " 0

$0   
  7       7      0, 7    "0   ( 1 
   8 9  ( ((4 9 (  " 9  7  "   9    1"0
$     ((  4 9 18  ( 60 (  1" (4    7 7
(( 9     7    1 "1( 4   "   0
  (
  1 "  9   (      7  4    ( 8 9    7
         1    (    (  0

 ((  @"   9 7  "  1    " (0 =    9 
77  (1  "1( U  9 (      (0    79 
 (( 7  0

// Create a list that we'll put values of factorial in.
ArrayList factorial = new ArrayList();

// Compute first 10 factorials.


int fact = 1;
for (int i = 1; i <= 10; i++)
{
fact *= i;
factorial.Add(fact);
}

'





   


// Print them.
for (int i = 0; i < 10; i++)
{
int value = (int) factorial[i];
Console.WriteLine(value);
}

 9  "   &%      7   B  7 , " 7  7 7"  
 0   98  ;(4  9  (1H  7 "   9    "   ) (
 * 9    " 7   0 &  (  "  8 B        9
   " 9    8      0 & 7  "  4 9   7 8  
 (   " 9 9 1       9" 1 (71      9  0 
  "  4       1 1   1@ 7   (4    9  ( 
 9    )     .7  (*  1  0     1;    " 1; 
" 1 (7 9       7   7   0 &       " 
 ;1   (     (1     1@           0
 9 "   ( 7   " 0

& 7  (1      " B    9      9     0
=7  9  9   4   7   9" ((4  9" 1 (1    1; 
  " 1;     (  8             7  (  7
   1@  0    0

, 

  
  (( 7  19   .9 7  ( "  4 1"       1 "0

// Create a list that we'll put values of factorial in.
List<int> factorial = new List<int>();

// Compute first 10 factorials.


int fact = 1;
for (int i = 1; i <= 10; i++)
{
fact *= i;
factorial.Add(fact);
}

// Print them.
for (int i = 0; i < 10; i++)
{

''





   



int value = factorial[i];
Console.WriteLine(value);
}


O       1    (0 9 7        0

List<int> factorial = new List<int>();


 7        ( %   %&  1  "0 %   9 (   0,   
   9 0 0K  (0  1 77     9    ; 
" 0 &7  ( %4  (     1   4 (    180     (
( )"   ( ((*4    (7  ( 7 "  9 1    
 0

      (      9 ((0  ( 9 8 9    
    4   7        8  " 0 "  4   9 (1 7 
"   (   4      7 1;    " 1; 4     (7   
1   0

 4   9 ((  7  79      7  7 (0

factorial[2] = "Monkey!";


$    (4  9" (0
9 4  ( 9"   " 0

1
2
System.InvalidCastException was unhandled
at CSharp2Examples.Program.Main(String[] args)

2     % (    ( 9   "  7  8 9        B  
  " 1     0    (  ( 9 "    0

Cannot implicitly convert type 'string' to 'int'

&  ;( 7       9 +  (0 =   " 9      7
 7 (( )7 (  * 9    )7 (  *0 &  " 9" 1  " 

 1  4 9    8      "0

HashTable ages = new HashTable();

'6





   



 +     (. (  7 
 14 1" 9  ( 7  8   "
(0 =      790

Dictionary<string, int> ages = new Dictionary<string, int>();


   ( 8 9 ( ( B   7  8     7  "0 $    
( (  ( 4   ( 1 4 @"  ( 1  (    9" 10
= 74  9    4      ( "  ( 9 " (    ( 7
" 9 0

 4  9 8      (1      7  7    0   9  "
 ;(

List<List<int>> nested = new List<List<int>>();



 C #         
 = C         = C$   
!" $  6        $    
  C
 

   '( 


=  (1   " 9   (    9  "   "((  0   "7" 9 "
       (    7"   7     (  "( 7 (0  ;(4
  = 9    9   ((  8  7" "  1@    "0 =7   "
 1  " ((  9     180 =7 4  9   18  7" "0 = 9   "
 7  4 7    1@ (0

O  ( =     (    794 "   1@ (       1    0

class DefaultProxy
{
private object defaultObject;
private object stored;

// Set the default object we'll return if nothing has been


// set.
public DefaultProxy(object o)
{
defaultObject = o;
}

'-





   



// Property for object o.
public object target
{
get
{
return stored == null ? defaultObject : stored;
}
set
{
stored = value;
}
}
}


 9 984 1"    "    .(   9 9 0 &  ( 9"
1  9  ( ( 7   7  (4 7 ;( = +7";4 +7"; 0
    1 4   7  1"  7"        1 "(0

K  (   " 0 "     1       (    9 (0  7  
(  ( B  4     8  ( (0     "     18
 ;4     "  9   (  9 7    0

class DefaultProxy<T>


$  > ?  ( 10 #" 8 9  "  1  9  9 9" "  "4 9  "  (
1  9  9 9" "  (0 74 9  (  " 7  >1@? (   1 
 9  ( 14  9 190

class DefaultProxy<T>
{
private T defaultObject;
private T stored;

// Set the default object we'll return if nothing has been


// set.
public DefaultProxy(T o)
{
defaultObject = o;
}

// Property for object o.


public T target

'/





   



{
get
{
return stored == null ? defaultObject : stored;
}
set
{
stored = value;
}
}
}


&    B 9  @"     (0 =     1 "((   (  " 7 ( 1 > ?U
  ;( 19 9  9    7    (4   ( 9       9
 0

DefaultProxy<int> proxy1 = new DefaultProxy<int>();
DefaultProxy<string> proxy2 = new DefaultProxy<string>();


=  ( "   8 7  9 > ? 1  ;" "1" 9   > ?  7"    +7";
4 " 1 9  "       9  (( 0

  '((   


   (  9    7 9    1 ( 9   (0
9 4 
   "  (7  (     ((   (0    79  (0

class MyGenericType<T>
{
private T item;

public void PerformSomeOperation()


{
foreach(object o in item)
{
// do something
}
}
}


     (   "1 )7 ;(4     *4 (   (   9 "  


'3





   




foreach statement cannot operate on variables of type 'T' because 'T' does not
contain a public definition for 'GetEnumerator'

  "  4 9    ( 1 > ? "   " 9 (   = "1
 70     "   9 >9? 89   9  > ?  ;4  " 7 (7  9
    7   9  7  ( 0

class MyGenericType<T> where T : IEnumerable


  9 9 (4   (   9   (  (   = "1  7 9
"0

MyGenericType<List<int>> chimp = new MyGenericType<List<int>>();

9 4 "((   ( 7  ( (    (  = "14 "  > ?4 9   
(  0

The type 'int' must be convertible to 'System.Collections.IEnumerable' in order
to use it as parameter 'T' in the generic type or method
'CSharp2Examples.MyGenericType<T>'

!    (1     ( 1 "   " (       7   
7   (     (       70   4 @" (  1 0

class MyGenericType<T> where T : IEnumerable, IComparable


 "((    7    ( 14  >9? 89 " 1 (     7 
  0 %   "  =      F"4 1" (( 8       0

class MyGenericType<T, U> where T : IEnumerable, IComparable
where U : ICollection


=   (1     (    ( 7   " ( "      "
890 !      " (( 17    7        7    (
10

class MyGenericType<T, U> where T : struct
where U : class


=7 9 (      ( " 9       9 (    1  ( 14 
" " 1       "0  9)*     1 "  (7    (  

'C





   



  (  ( 9 " (   7" (  "0 !  7    (
1     "  7   4         "  9  "   0

class MyGenericType<T> where T : new()


 $$   
=7 "  AA (  "  (11  "   8  >=     174  @"
(  ?0 AA (  98  7 ( ((4 9    (
90  4 (   ;  "  B  ( "  (  ("   4  
7  (  (  ( 90 = 9 8  ;  7   B    ;"
"1" 0

#       4 9  ; 9      4 1"  9 AA (  
 ( 90  9      "  ) #NE*      1 7  "((  0

9 4   " 9 (10  7   7 )8   (  " *    
( (0      "   (7  1 74      (   
( " @" (   ( 1 9 O1@        F"0 7
(    (  )  .7 * (   1;    " 1; 0

= 0!4  "   1 7  1 9 7  0 $  18 189 (1 9
( "   7  " 4       ; 9 "  7     ( 
" ( 7 9      1;    " 1;   0


    $ E *    < +  $  
   C       
   D =   DD     DF$D

& 
 '( 
$ = 7    ( ( = "  9    1   ; 0 &7 4 ( (
 ( 0 = "  "    " F" 1  1 ( 4 1"  87"    "  0
 " 7  9 >(?   7   (  " 7  "7 B  4    " )1" 
 " *0  >(? 1 (    "    7    ( 7     0
 4 "     ( >  ( 7  7  7   B  7  7   
7   B 1"   1  ( 9?0





'5





   





(  & V
  ;U
 &  V
 )* V d W   ;U
W
 )* V d W
(   U

  )* V d W
(  &  V
W
  U
  )* V d W
W


 9 7 ( (     7   9 1 (   "( 70    " 7
   N" "   K2=  4 9 ( 7   7  9 9        
"0 $ ( (  "             ( 70
&  "   9 9 ( 9   98  77   7       0
=7 9 ( 7 9     1   (" (4   (  1 ("    ( 
 ( 70 =   1 "7" 7 9           1 9  (  "(4 1"
" " (11 1 8  9        " 7 "    0

  ;  ( B  (7   ( 7    1 7  9 @"   9 >(?
70  ;(4   9     7       (0 $  9  ( " 
77  ( 7    (     ( 70  ;(4   7 >+ 8 0? 9 
 

partial class PartyGoer
{
private int drinksHad;
private bool drunk;

public void HaveADrink(string drinkName)


{
// ...
}
}


$  7 > (0?  ((  

partial class PartyGoer
{

'',





   



public string[] FindAttractivePeople()
{
// ...
}

public void ChatUp(string name)


{
// ...
}
}


!   (  7 7     7  7  (   1   ( 4   
    0 7  > (0?   (7   9      ( 
7 7  7  7   7   >+ 8 0?0

public void AskToMarry(string name)
{
if (drunk)
{
// Ask!
}
else
{
throw new ThatIsAReallyStupidIdeaException();
}
}


   ( 9 B    ;  " 0  (   7  7  7 
    (   7    1 (7 0    4  7  7   "
1    10 !     F"  (7   7   (  1    
   ( 7   7  B  ( 9 8  "  7        ( 0
74 7 "     7 77    77  ( 7  4 "   (  0
&9 1     @"    9  7  ( "(0

     (   8  (  "  1 1   (  "(
7"  0
9 4    8   9 " 8 1"    "    ( 
1" "       9 7   9     7   9  7 
(  B "    7   7  7  7    1 "0 & 7  7      
  ( 4 9      " "( 70

=    "   (  "  1 "4 1" = 9"  " 7"   
9  "     8 7    7    9       7 "0

''





   





            -  
      /-    
 G    
    =   $  
       H  I    &C G
       # C
  > !"  




 '( 
$   9 7  (   (1    7   "4        1@ 1 
7 0   1 "    4 7 ;(4  "7"  9  1  10 Q" 
   " 9 7   7  1 B 7  F" 7  7   94  " 7   1
"     U 94  7   1@ (     9  9 7"   1 " 0

!9    " 9 9    F" 1" @" 9    " 184    " 1 7 
9 @" " 4 7 ;(4   0 & (1  4 7 9 " (    " "0 O 
" 4 7        1  74   8  " 7   >   9 7" ?0   
9 (14 9  B          9    9        "0

!"1 (   (1 1 9  " (  8  " "0  (7   " (
" 1 "14 ( (  F" 8 7   7  (

int? x = null;
double? y = 5.2;


!  9  9  1  1    "4 9    "0   9  "1 1
 1    "  7   "4    7 F"  "  " 9" 9  7    
1
N" ((4 9 9 1   7 7  1  "0

if (x != null) // Alternatively, if (x.HasValue)
{
// It's not null.
}
else
{
// It is null.
}


Q"  (7     (   "1 " ( @"  " 9"    . "1
 0  1  ;   9  1   "0

int? x = 6;

''





   



int? y = 7;
int? z = x * y; // z is now 42

9 4 7  " 1   " 9  "      ;( 4  " 7 
9 ;( 1 "0

int? x = 6;
int? y = null;
int? z = x * y; // z is now null


 4    ;  ; 7     7" " 7  "1 1  "0    9 "
  (4 9  ( >HH?0 =  "7" 9     "1 (    . "1 (0

int? x = 5;
int? y = null;
int a = x ?? 0; // a is 5
int b = y ?? 0; // b is 0


+     "1 1   1 7  F"    . "1 (   (  0


int? x = 5;
int a = x; // Ooh, naughty.


Q"     4 9 (  ( (  

int? x = 5;
int a = (int) x; // OK

9 4 7 ; 9 "



int? x = null;
int a = (int) x;


  9 (4 1"  ;( 9 1 9  " 0

System.InvalidOperationException was unhandled
Message="Nullable object must have a value."

     "  ;( 4 9  1 "7" 7   4 " "  1 1 
9   (7" ;( ;(0

'''





   



 F" 8  ;   "   (   @"   "0 2     (
9  "   !"1 (4 9     " (     0!  10 7 
0!  " 9" ( "(( 7 "1 (   98 9 0
    ;( 7 " 
 !"1 ( 4 9  (       0

Nullable<int> x = null; // Same as int? x = null;
int a = x.HasValue ? x.Value : 0; // Same as int a = x ?? 0;


!"1 (    ;( 7 9    1 ("   "0

/'  $ 5 $



+    1 "     0  4   7 8 9    7    
1  4 9    7      8   "  7 0 + 7  1 7  0!
   4     " (   9         d

public void MyButton_OnClick(object sender, EventArgs e)
{
// Handle the event…
}


d       "  7    0

myButton.Click += new EventHandler(MyButton_OnClick);


2"          )E" [O 8   *       9    
" .  4        "        "   0 "4     
        79   7   0 &4  9" 1   1 1  9 9   
    "1(       0 &  "    7  1    
 1  1  "     (   "((  (  7      9
7   790   ; 7    "    790

myButton.Click += delegate(object sender, EventArgs e)
{
// Handle the event...
};


!   7   8 9    "1(       4 1"   7 (7 
9   "11    4  9  (  1   "   89 >?0
= 79    7   (    14   1   7 
  " 184 9    70  ( 7   9 1 1 "  
(7    ( 7  4    190

''6





   




myButton.Click += delegate(object sender, System.EventArgs e)
{
MessageBox.Show(e.ToString());
};

/5    $'  $ 


 7   "   ((  1      8  "  "  7    
1 9 7     0 O  7    8  9  (97"      
1 7       1   0    79  (0

// Create a list containing the numbers 1 to 10.
List<int> numbers = new List<int>();
for (int i = 1; i <= 10; i++)
numbers.Add(i);

// Add them all together.


int sum = 0;
numbers.ForEach(delegate(int x) { sum += x; });
Console.WriteLine(sum); // Prints 55


     7  1        " 7    " 0    8
  7    7  "    8   "  0 !   
7  " 1 7   (  8   ( )7 (     *0
    " 
 7  1 79    7  9  " 8 7   " 10 $  (( 9
"(    9  "  1 >"?      " 0 =  1  ;( 9   
 1  "  9 (0     @"  ( 9  9  7 (4 1"   F"
 7       1 "   9  7 " 0

Q"    (  1 9   9 ((  7 " "    7     " 
 "   7   1      0 "  1          
      ;" 4   "  1 7  1    "  9    ;H =
74     0   9  79  ( 9  9 " " 0

using System;
using System.Collections.Generic;

namespace CSharp2Examples
{
// A new delegate type that takes no parameters and returns
// an integer.

''-





   



delegate int Counter();

class Program
{
static Counter GetCounter(int start)
{
// Counter variable outside of the anonymous method.
int count = start;

// Return our counter method.


return delegate()
{
count++;
return count;
};
}

static void Main(string[] args)


{
// Create a counter starting at 15.
Counter c = GetCounter(15);

// Loop 5 times calling the anonymous method.


for (int i = 0; i < 5; i++)
{
int value = c();
Console.WriteLine(value);
}
}
}
}


 ( 9    79  "("

16
17
18
19
20

  1 >" ?  9 1  8( " 0 2     (  "    7
1 ( 7      7 4      "     (     

''/





   



" >(?   4  9    "       1  0  8  7 
  "   7  9 ("      "       (11 (   
(7" 9 7  8  1" 9     4 "0  (  8 9  8   "0


     
              
 C               
      $    &     
          !       
  
       GC   
$  


 $$  
 (       9 7"   0,4 1"   ;( 7" 7   @   
9  1 "   (  1"   77  " 4 "" 9  770 = (  (  
@" ;(   7"4 1"    "  7 7 9   (   9 8  7 (1  
((1 0 1   9    1;   9  1    (   " (1 B 1"
  1 7   "  9  J

''3





   


.$8/$

 1 
 7"    0! 798      " 9"     (   18 0

9 4 9 (    F"(( " 9  "77  "    7    "    0!
(7 4   9   "  4 " 9 1   8   9 (  80

 ( " 7 "  7  0!  1   E+! )E7 + ( !98*0 
"       14    7  1   7 (   " ;(0  
1 7"   ( << 070< ."<1<5''-0(;0


     7     0     "  7    9   7
(4 7 1"  DE%4  9     7    "    1 7 9 0 
     "  1     B @"  7 J

, 3
(
    (1H K "8H +  9 B (   10    "1 7 (  "  "
    0! 798 9 4  "   1   =  0 
   
  14   ( <<9990(  0<<E<99910(H]'30

79 5 ==


   7  7    .184 1" 9 (   9  1  0 "" "(   "
 7 9  " 7"   7   ' 7    "  9    ( 
 9 " 7    0!4 ((  "  &0!4 91     DE%0

$  (  7"" 7  18  " B   B  (      9 "    " 8 9
9 " 9" 8   (   0 
   1  1  
 7P(  0    .18   ( 9   9 1"   
( <<9990(  0<<(8

,9O
 "     7  18 9 "  1 7 "8 9       (  ((  " 
    0! (70
((  J

''C

Você também pode gostar