Welcome to Scribd, the world's digital library. Read, publish, and share books and documents. See more
Download
Standard view
Full view
of .
Look up keyword
Like this
18Activity
0 of .
Results for:
No results containing your search query
P. 1
csharp

csharp

Ratings:

3.0

(1)
|Views: 161|Likes:
Published by api-19913071

More info:

Published by: api-19913071 on Dec 02, 2009
Copyright:Attribution Non-commercial

Availability:

Read on Scribd mobile: iPhone, iPad and Android.
download as PDF, TXT or read online from Scribd
See more
See less

03/18/2014

pdf

text

original

Programming in CSharp
by
Willi-Hans Steeb
International School for Scienti\ufb01c Computing
and
E.J. Dembskey
Version: 2009-01-06
email addresses of the authors:

steeb_wh@yahoo.com
steebwilli@gmail.com
whsteeb@uj.ac.za
evan.dembskey@gmail.com
demskeye@tut.ac.za

Contents
1 Introduction
1
2 CSharp Basics
6

2.1 Introduction. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6 2.2 Basic Data Types. . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9 2.3 ASCIITable. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11 2.4 ArithmeticOperations. . . . . . . . . . . . . . . . . . . . . . . . . . 13 2.5 ControlStatements. . . . . . . . . . . . . . . . . . . . . . . . . . . . 14 2.6 LogicalOperations. . . . . . . . . . . . . . . . . . . . . . . . . . . . 18 2.7 Pointers. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19 2.8 Recursion. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20 2.9 JumpStatements. . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21 2.10 Pass by Value, Pass by Reference. . . . . . . . . . . . . . . . . . . . 22 2.11 Arrays. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26 2.12 Bitwise Operations. . . . . . . . . . . . . . . . . . . . . . . . . . . . 28 2.13 Shift Operation. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29 2.14 Commmand-Line Arguments. . . . . . . . . . . . . . . . . . . . . . . 30 2.15 Boxing and UnBoxing Types. . . . . . . . . . . . . . . . . . . . . . . 31 2.16 Delegates. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31 2.17 Types. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32 2.18 Re\ufb02ection. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33 2.19 Generics. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34 2.20 Indexers. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 40

3 String and StringBuilder
43

3.1 StringClass. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 43 3.2 ConvertClass. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45 3.3 StringBuilderClass. . . . . . . . . . . . . . . . . . . . . . . . . . . . 46

4 Built-in Classes
48

4.1 DateTimeClass. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 48 4.2 ArrayClass. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 49 4.3 ArrayListClass. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 50 4.4 ListDictionaryClass. . . . . . . . . . . . . . . . . . . . . . . . . . . 51 4.5 ClassIEnumerator. . . . . . . . . . . . . . . . . . . . . . . . . . . . 52

i

4.6 MathematicsClass. . . . . . . . . . . . . . . . . . . . . . . . . . . . 52 4.7 RandomClass. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 55 4.8 PointClasses. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 56 4.9 ClassBitArray. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 57 4.10 Object Class. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 58 4.11 Environment Class. . . . . . . . . . . . . . . . . . . . . . . . . . . . 61

5 Object-Oriented Programming
63

5.1 Write your own class. . . . . . . . . . . . . . . . . . . . . . . . . . . 63 5.2 OverrideMethods. . . . . . . . . . . . . . . . . . . . . . . . . . . . . 69 5.3 Inheritance. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 71 5.4 OverloadingMethods. . . . . . . . . . . . . . . . . . . . . . . . . . . 75 5.5 OperatorOverloading. . . . . . . . . . . . . . . . . . . . . . . . . . . 76 5.6 Structures and Enumerations. . . . . . . . . . . . . . . . . . . . . . 77 5.7 Delegates. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 78

6 Streams and File Manipulations
83

6.1 Introduction. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 83 6.2 Binary File Manipulations. . . . . . . . . . . . . . . . . . . . . . . . 83 6.3 Text File Manipulation. . . . . . . . . . . . . . . . . . . . . . . . . . 85 6.4 Byte by Byte Manipulation. . . . . . . . . . . . . . . . . . . . . . . 88 6.5 ObjectSerialization. . . . . . . . . . . . . . . . . . . . . . . . . . . . 90 6.6 XMLDocuments. . . . . . . . . . . . . . . . . . . . . . . . . . . . . 93

7 Graphics
96

7.1 DrawingMethods. . . . . . . . . . . . . . . . . . . . . . . . . . . . . 96 7.2 ColorClass. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 99 7.3 Button and EventHandler. . . . . . . . . . . . . . . . . . . . . . . . 101 7.4 DisplayingImages. . . . . . . . . . . . . . . . . . . . . . . . . . . . . 103 7.5 OverridingOnPaint. . . . . . . . . . . . . . . . . . . . . . . . . . . . 104

8 Events
110
9 Processes and Threads
114
9.1 Processes. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 114

9.2 Threads. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 115 9.2.1 Introduction. . . . . . . . . . . . . . . . . . . . . . . . . . . . 115 9.2.2 BackgroundThread. . . . . . . . . . . . . . . . . . . . . . . .116 9.2.3 SleepMethod. . . . . . . . . . . . . . . . . . . . . . . . . . .117

9.2.4 JoinMethods. . . . . . . . . . . . . . . . . . . . . . . . . . .119 9.3 Monitor. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 120 9.4 Synchronization. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 121 9.5 Deadlock. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 123 9.6 InterlockedClass. . . . . . . . . . . . . . . . . . . . . . . . . . . . . 125 9.7 ThreadPooling. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 126 9.8 Threading in Windows Forms. . . . . . . . . . . . . . . . . . . . . . 127

ii

Activity (18)

You've already reviewed this. Edit your review.
1 hundred reads
Mukesh Bisht liked this
zabig liked this
guydude liked this
guydude liked this
guydude liked this
eswargondi liked this
eswargondi liked this
Shruthi Sirige liked this
triveni85 liked this

You're Reading a Free Preview

Download
scribd
/*********** DO NOT ALTER ANYTHING BELOW THIS LINE ! ************/ var s_code=s.t();if(s_code)document.write(s_code)//-->