Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in
Toggle navigation
Programming C 3rd Edition
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
examples
Programming C 3rd Edition
Commits
906d27b3
Commit
906d27b3
authored
Jun 27, 2017
by
O'Reilly Media, Inc.
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Initial commit
parents
Changes
193
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
193 changed files
with
3459 additions
and
0 deletions
+3459
-0
Makefile
ProgCSharpSrcUpdate20/Chapter 10/Makefile
+40
-0
ex-10-01 strings
ProgCSharpSrcUpdate20/Chapter 10/ex-10-01 strings
+95
-0
ex-10-02 Substring
ProgCSharpSrcUpdate20/Chapter 10/ex-10-02 Substring
+68
-0
ex-10-03 Split
ProgCSharpSrcUpdate20/Chapter 10/ex-10-03 Split
+41
-0
ex-10-04 StringBuilder
ProgCSharpSrcUpdate20/Chapter 10/ex-10-04 StringBuilder
+41
-0
ex-10-05 Regex
ProgCSharpSrcUpdate20/Chapter 10/ex-10-05 Regex
+29
-0
ex-10-06 static Regex
ProgCSharpSrcUpdate20/Chapter 10/ex-10-06 static Regex
+25
-0
ex-10-07 MatchCollection and Match
...SrcUpdate20/Chapter 10/ex-10-07 MatchCollection and Match
+37
-0
ex-10-08 Group class
ProgCSharpSrcUpdate20/Chapter 10/ex-10-08 Group class
+41
-0
ex-10-09 capture collection
ProgCSharpSrcUpdate20/Chapter 10/ex-10-09 capture collection
+54
-0
Makefile
ProgCSharpSrcUpdate20/Chapter 11/Makefile
+37
-0
ex-11-01 Throwing an exception
...harpSrcUpdate20/Chapter 11/ex-11-01 Throwing an exception
+34
-0
ex-11-02 Catching an exception
...harpSrcUpdate20/Chapter 11/ex-11-02 Catching an exception
+42
-0
ex-11-03 Catch in a calling function
...cUpdate20/Chapter 11/ex-11-03 Catch in a calling function
+43
-0
ex-11-04 Specifying the exception
...pSrcUpdate20/Chapter 11/ex-11-04 Specifying the exception
+59
-0
ex-11-05 finally block
ProgCSharpSrcUpdate20/Chapter 11/ex-11-05 finally block
+58
-0
ex-11-06 exception object
ProgCSharpSrcUpdate20/Chapter 11/ex-11-06 exception object
+72
-0
ex-11-07 custom exception
ProgCSharpSrcUpdate20/Chapter 11/ex-11-07 custom exception
+93
-0
ex-11-08 Rethrowing and inner exceptions
...ate20/Chapter 11/ex-11-08 Rethrowing and inner exceptions
+112
-0
12-2.cs
ProgCSharpSrcUpdate20/Chapter 12/12-2.cs
+125
-0
Makefile
ProgCSharpSrcUpdate20/Chapter 12/Makefile
+25
-0
ex-12-01 delegates
ProgCSharpSrcUpdate20/Chapter 12/ex-12-01 delegates
+163
-0
ex-12-02 array of delegates
ProgCSharpSrcUpdate20/Chapter 12/ex-12-02 array of delegates
+125
-0
ex-12-03 Combining delegates
...CSharpSrcUpdate20/Chapter 12/ex-12-03 Combining delegates
+107
-0
ex-12-04 Working with events
...CSharpSrcUpdate20/Chapter 12/ex-12-04 Working with events
+151
-0
Makefile
ProgCSharpSrcUpdate20/Chapter 13/Makefile
+22
-0
ex-13-01 hand-drawn Windows Form
...rpSrcUpdate20/Chapter 13/ex-13-01 hand-drawn Windows Form
+70
-0
ex-13-02 IDE Source code
ProgCSharpSrcUpdate20/Chapter 13/ex-13-02 IDE Source code
+113
-0
ex-13-03 WinForms demonstration
...arpSrcUpdate20/Chapter 13/ex-13-03 WinForms demonstration
+0
-0
Makefile
ProgCSharpSrcUpdate20/Chapter 14/Makefile
+31
-0
ex-14-01 ADO_NET
ProgCSharpSrcUpdate20/Chapter 14/ex-14-01 ADO_NET
+89
-0
ex-14-02 ADO Managed Provider
...SharpSrcUpdate20/Chapter 14/ex-14-02 ADO Managed Provider
+90
-0
ex-14-03 DataGrid
ProgCSharpSrcUpdate20/Chapter 14/ex-14-03 DataGrid
+90
-0
ex-14-04 Dataset
ProgCSharpSrcUpdate20/Chapter 14/ex-14-04 Dataset
+95
-0
ex-14-05 DataGrid with two tables
...pSrcUpdate20/Chapter 14/ex-14-05 DataGrid with two tables
+125
-0
ex-14-06 Updating records
ProgCSharpSrcUpdate20/Chapter 14/ex-14-06 Updating records
+0
-0
ex-14-06 Updating records.txt
...SharpSrcUpdate20/Chapter 14/ex-14-06 Updating records.txt
+0
-0
Makefile
ProgCSharpSrcUpdate20/Chapter 15/Makefile
+16
-0
ex-15-01 HTML
ProgCSharpSrcUpdate20/Chapter 15/ex-15-01 HTML
+22
-0
ex-15-02 aspx file
ProgCSharpSrcUpdate20/Chapter 15/ex-15-02 aspx file
+60
-0
ex-15-03 page supporting the HTML
...pSrcUpdate20/Chapter 15/ex-15-03 page supporting the HTML
+123
-0
Chapter 16 Putting It Together.zip
...SrcUpdate20/Chapter 16/Chapter 16 Putting It Together.zip
+0
-0
Makefile
ProgCSharpSrcUpdate20/Chapter 16/Makefile
+24
-0
ex-16-01 Skeleton web class
ProgCSharpSrcUpdate20/Chapter 16/ex-16-01 Skeleton web class
+66
-0
ex-16-02 Calculator program
ProgCSharpSrcUpdate20/Chapter 16/ex-16-02 Calculator program
+82
-0
ex-16-03 Sample client code
ProgCSharpSrcUpdate20/Chapter 16/ex-16-03 Sample client code
+54
-0
ex-16-04 client program
ProgCSharpSrcUpdate20/Chapter 16/ex-16-04 client program
+36
-0
Makefile
ProgCSharpSrcUpdate20/Chapter 17/Makefile
+10
-0
ex-17-01 Fraction class
ProgCSharpSrcUpdate20/Chapter 17/ex-17-01 Fraction class
+36
-0
ex-17-02 Calculator
ProgCSharpSrcUpdate20/Chapter 17/ex-17-02 Calculator
+19
-0
ex-17-03 makefile for a multi-module assembly
.../Chapter 17/ex-17-03 makefile for a multi-module assembly
+37
-0
ex-17-04 module test driver
ProgCSharpSrcUpdate20/Chapter 17/ex-17-04 module test driver
+39
-0
Makefile
ProgCSharpSrcUpdate20/Chapter 18/Makefile
+48
-0
ex-18-01 custom attributes
ProgCSharpSrcUpdate20/Chapter 18/ex-18-01 custom attributes
+106
-0
ex-18-02 Reflection
ProgCSharpSrcUpdate20/Chapter 18/ex-18-02 Reflection
+35
-0
ex-18-03 Reflecting on an assembly
...SrcUpdate20/Chapter 18/ex-18-03 Reflecting on an assembly
+23
-0
ex-18-04 Reflecting on a type
...SharpSrcUpdate20/Chapter 18/ex-18-04 Reflecting on a type
+21
-0
ex-18-05 Reflecting on the members of a type
...0/Chapter 18/ex-18-05 Reflecting on the members of a type
+29
-0
ex-18-06 Finding particular members
...rcUpdate20/Chapter 18/ex-18-06 Finding particular members
+33
-0
ex-18-07 Dynamically invoking a method
...pdate20/Chapter 18/ex-18-07 Dynamically invoking a method
+37
-0
ex-18-08 Comparing loop to brute force
...pdate20/Chapter 18/ex-18-08 Comparing loop to brute force
+0
-0
ex-18-09 invocation with Type and InvokeMethod
...Chapter 18/ex-18-09 invocation with Type and InvokeMethod
+0
-0
ex-18-10 invocation with interfaces
...rcUpdate20/Chapter 18/ex-18-10 invocation with interfaces
+0
-0
ex-18-11 invocation with reflection emit
...ate20/Chapter 18/ex-18-11 invocation with reflection emit
+0
-0
Makefile
ProgCSharpSrcUpdate20/Chapter 19/Makefile
+36
-0
ex-19-01 Marshaling
ProgCSharpSrcUpdate20/Chapter 19/ex-19-01 Marshaling
+0
-0
ex-19-02 Calculator interface
...SharpSrcUpdate20/Chapter 19/ex-19-02 Calculator interface
+14
-0
ex-19-03 Calculator server
ProgCSharpSrcUpdate20/Chapter 19/ex-19-03 Calculator server
+0
-0
ex-19-04 remoting Calculator client
...rcUpdate20/Chapter 19/ex-19-04 remoting Calculator client
+0
-0
ex-19-05 instantiating and associating Calculator
...pter 19/ex-19-05 instantiating and associating Calculator
+0
-0
ex-19-06 Marshaling an object without an endpoint
...pter 19/ex-19-06 Marshaling an object without an endpoint
+0
-0
ex-19-07 Replacement of Main from Example 19-4_the client
...ex-19-07 Replacement of Main from Example 19-4_the client
+0
-0
Makefile
ProgCSharpSrcUpdate20/Chapter 2/Makefile
+0
-0
ex-02-01 simple program
ProgCSharpSrcUpdate20/Chapter 2/ex-02-01 simple program
+11
-0
ex-02-02 multiline comments
ProgCSharpSrcUpdate20/Chapter 2/ex-02-02 multiline comments
+0
-0
ex-02-03 using keyword
ProgCSharpSrcUpdate20/Chapter 2/ex-02-03 using keyword
+0
-0
ex-02-04 does not compile
ProgCSharpSrcUpdate20/Chapter 2/ex-02-04 does not compile
+0
-0
Makefile
ProgCSharpSrcUpdate20/Chapter 20/Makefile
+0
-0
ex-20-01 Using threads
ProgCSharpSrcUpdate20/Chapter 20/ex-20-01 Using threads
+0
-0
ex-20-02 Interrupting a thread
...harpSrcUpdate20/Chapter 20/ex-20-02 Interrupting a thread
+0
-0
ex-20-03 Simulating a shared resource
...Update20/Chapter 20/ex-20-03 Simulating a shared resource
+0
-0
ex-20-04 Using a Monitor object
...arpSrcUpdate20/Chapter 20/ex-20-04 Using a Monitor object
+0
-0
Makefile
ProgCSharpSrcUpdate20/Chapter 21/Makefile
+0
-0
ex-21-01 Recursing through subdirectories
...te20/Chapter 21/ex-21-01 Recursing through subdirectories
+0
-0
ex-21-02 Exploring files and subdirectories
...20/Chapter 21/ex-21-02 Exploring files and subdirectories
+0
-0
ex-21-03 Creating a subdirectory and manipulating files
...1/ex-21-03 Creating a subdirectory and manipulating files
+0
-0
ex-21-04 Implementing a binary read and write to a file
...1/ex-21-04 Implementing a binary read and write to a file
+0
-0
ex-21-05 Implementing buffered In_Out
...Update20/Chapter 21/ex-21-05 Implementing buffered In_Out
+0
-0
ex-21-06 Reading and writing to a text file
...20/Chapter 21/ex-21-06 Reading and writing to a text file
+0
-0
ex-21-07 Implementing asynchronous In_Out
...te20/Chapter 21/ex-21-07 Implementing asynchronous In_Out
+0
-0
ex-21-08 Implementing a network streaming server
...apter 21/ex-21-08 Implementing a network streaming server
+0
-0
ex-21-09 Implementing a network streaming client
...apter 21/ex-21-09 Implementing a network streaming client
+0
-0
ex-21-10 Implementing an asynchronous network streaming server
...-10 Implementing an asynchronous network streaming server
+0
-0
ex-21-11 Implementing a client for asynchronous network
...1/ex-21-11 Implementing a client for asynchronous network
+0
-0
ex-21-12 Implementing an asynchronous network file server
...ex-21-12 Implementing an asynchronous network file server
+0
-0
ex-21-13 Implementing a client for an asynchronous network file server
...ementing a client for an asynchronous network file server
+0
-0
ex-21-14 Reading a web page as an HTML stream
.../Chapter 21/ex-21-14 Reading a web page as an HTML stream
+0
-0
ex-21-15 Serializing and deserializing an object
...apter 21/ex-21-15 Serializing and deserializing an object
+0
-0
ex-21-16 Working with a nonserialized object
...0/Chapter 21/ex-21-16 Working with a nonserialized object
+0
-0
ex-21-17 iWriting to isolated storage
...Update20/Chapter 21/ex-21-17 iWriting to isolated storage
+0
-0
ex-21-18 Reading from isolated storage
...pdate20/Chapter 21/ex-21-18 Reading from isolated storage
+0
-0
Makefile
ProgCSharpSrcUpdate20/Chapter 22/Makefile
+0
-0
VB6.zip
ProgCSharpSrcUpdate20/Chapter 22/VB6.zip
+0
-0
ex-22-01 CalcControl ActiveX control
...cUpdate20/Chapter 22/ex-22-01 CalcControl ActiveX control
+0
-0
ex-22-02 CalcControl ActiveX control in a VB program
...r 22/ex-22-02 CalcControl ActiveX control in a VB program
+0
-0
ex-22-03 event handlers for the test Windows Form
...pter 22/ex-22-03 event handlers for the test Windows Form
+0
-0
ex-22-04 Implementing the methods for ComCalc
.../Chapter 22/ex-22-04 Implementing the methods for ComCalc
+0
-0
ex-22-05 driver program for ComCalc_dll
...date20/Chapter 22/ex-22-05 driver program for ComCalc_dll
+0
-0
ex-22-06 event handlers for the VB 6 COM DLL test form
...22/ex-22-06 event handlers for the VB 6 COM DLL test form
+0
-0
ex-22-07 binding of COM objects
...arpSrcUpdate20/Chapter 22/ex-22-07 binding of COM objects
+0
-0
ex-22-08 four-function calculator in a DLL
...e20/Chapter 22/ex-22-08 four-function calculator in a DLL
+0
-0
ex-22-09 Calculator COM object with a Windows scripting host file
... Calculator COM object with a Windows scripting host file
+0
-0
ex-22-10 P_Invoke to call a Win32 API method
...0/Chapter 22/ex-22-10 P_Invoke to call a Win32 API method
+0
-0
ex-22-11 Declaring Win32 API methods for import into a C# program
... Declaring Win32 API methods for import into a C# program
+0
-0
ex-22-12 pointers
ProgCSharpSrcUpdate20/Chapter 22/ex-22-12 pointers
+0
-0
Makefile
ProgCSharpSrcUpdate20/Chapter 3/Makefile
+0
-0
ex-03-01 Initializing and assigning a variable
.../Chapter 3/ex-03-01 Initializing and assigning a variable
+0
-0
ex-03-02 Using an uninitialized variable
...date20/Chapter 3/ex-03-02 Using an uninitialized variable
+0
-0
ex-03-03 Assigning without initializing
...pdate20/Chapter 3/ex-03-03 Assigning without initializing
+0
-0
ex-03-04 Using symbolic constants
...rpSrcUpdate20/Chapter 3/ex-03-04 Using symbolic constants
+0
-0
ex-03-05 Using enumerations
ProgCSharpSrcUpdate20/Chapter 3/ex-03-05 Using enumerations
+0
-0
ex-03-06 Calling a method
ProgCSharpSrcUpdate20/Chapter 3/ex-03-06 Calling a method
+0
-0
ex-03-07 If_else
ProgCSharpSrcUpdate20/Chapter 3/ex-03-07 If_else
+0
-0
ex-03-08 Nested if
ProgCSharpSrcUpdate20/Chapter 3/ex-03-08 Nested if
+0
-0
ex-03-09 switch
ProgCSharpSrcUpdate20/Chapter 3/ex-03-09 switch
+0
-0
ex-03-10 goto
ProgCSharpSrcUpdate20/Chapter 3/ex-03-10 goto
+0
-0
ex-03-11 while loop
ProgCSharpSrcUpdate20/Chapter 3/ex-03-11 while loop
+0
-0
ex-03-12 do_while loop
ProgCSharpSrcUpdate20/Chapter 3/ex-03-12 do_while loop
+0
-0
ex-03-13 for loop
ProgCSharpSrcUpdate20/Chapter 3/ex-03-13 for loop
+0
-0
ex-03-14 Scope of variables in a for loop
...ate20/Chapter 3/ex-03-14 Scope of variables in a for loop
+0
-0
ex-03-15 continue and break
ProgCSharpSrcUpdate20/Chapter 3/ex-03-15 continue and break
+0
-0
ex-03-16 Division and modulus
...CSharpSrcUpdate20/Chapter 3/ex-03-16 Division and modulus
+0
-0
ex-03-17 prefix versus postfix
...SharpSrcUpdate20/Chapter 3/ex-03-17 prefix versus postfix
+0
-0
ex-03-18 ternary operator
ProgCSharpSrcUpdate20/Chapter 3/ex-03-18 ternary operator
+0
-0
ex-03-19 namespaces
ProgCSharpSrcUpdate20/Chapter 3/ex-03-19 namespaces
+0
-0
ex-03-20 Nesting namespaces
ProgCSharpSrcUpdate20/Chapter 3/ex-03-20 Nesting namespaces
+0
-0
Makefile
ProgCSharpSrcUpdate20/Chapter 4/Makefile
+0
-0
ex-04-01 Simple Time class
ProgCSharpSrcUpdate20/Chapter 4/ex-04-01 Simple Time class
+0
-0
ex-04-02 Passing values
ProgCSharpSrcUpdate20/Chapter 4/ex-04-02 Passing values
+0
-0
ex-04-03 Declaring a constructor
...arpSrcUpdate20/Chapter 4/ex-04-03 Declaring a constructor
+0
-0
ex-04-04 Using an initializer
...CSharpSrcUpdate20/Chapter 4/ex-04-04 Using an initializer
+0
-0
ex-04-05 Using static fields
ProgCSharpSrcUpdate20/Chapter 4/ex-04-05 Using static fields
+0
-0
ex-04-06 using construct
ProgCSharpSrcUpdate20/Chapter 4/ex-04-06 using construct
+0
-0
ex-04-07 Returning values in parameters
...pdate20/Chapter 4/ex-04-07 Returning values in parameters
+0
-0
ex-04-08 in_out_ref parameters
...SharpSrcUpdate20/Chapter 4/ex-04-08 in_out_ref parameters
+0
-0
ex-04-09 Overloading the constructor
...rcUpdate20/Chapter 4/ex-04-09 Overloading the constructor
+0
-0
ex-04-10 Varying return on overloaded methods
...0/Chapter 4/ex-04-10 Varying return on overloaded methods
+0
-0
ex-04-11 Using a property
ProgCSharpSrcUpdate20/Chapter 4/ex-04-11 Using a property
+0
-0
ex-04-12 static public constants
...arpSrcUpdate20/Chapter 4/ex-04-12 static public constants
+0
-0
Makefile
ProgCSharpSrcUpdate20/Chapter 5/Makefile
+0
-0
ex-05-01 derived class
ProgCSharpSrcUpdate20/Chapter 5/ex-05-01 derived class
+0
-0
ex-05-02 virtual methods
ProgCSharpSrcUpdate20/Chapter 5/ex-05-02 virtual methods
+0
-0
ex-05-03 abstract method and class
...pSrcUpdate20/Chapter 5/ex-05-03 abstract method and class
+0
-0
ex-05-04 Inheriting from Object
...harpSrcUpdate20/Chapter 5/ex-05-04 Inheriting from Object
+0
-0
ex-05-05 Boxing
ProgCSharpSrcUpdate20/Chapter 5/ex-05-05 Boxing
+0
-0
ex-05-06 nested class
ProgCSharpSrcUpdate20/Chapter 5/ex-05-06 nested class
+0
-0
Makefile
ProgCSharpSrcUpdate20/Chapter 6/Makefile
+0
-0
ex-06-01 fraction class
ProgCSharpSrcUpdate20/Chapter 6/ex-06-01 fraction class
+0
-0
Makefile
ProgCSharpSrcUpdate20/Chapter 7/Makefile
+0
-0
ex-07-01 struct
ProgCSharpSrcUpdate20/Chapter 7/ex-07-01 struct
+0
-0
ex-07-02 struct without using new
...rpSrcUpdate20/Chapter 7/ex-07-02 struct without using new
+0
-0
Makefile
ProgCSharpSrcUpdate20/Chapter 8/Makefile
+0
-0
ex-08-01 simple interface
ProgCSharpSrcUpdate20/Chapter 8/ex-08-01 simple interface
+0
-0
ex-08-02 Extending and combining interfaces
...e20/Chapter 8/ex-08-02 Extending and combining interfaces
+0
-0
ex-08-03 is operator
ProgCSharpSrcUpdate20/Chapter 8/ex-08-03 is operator
+0
-0
ex-08-04 Overriding an interface
...arpSrcUpdate20/Chapter 8/ex-08-04 Overriding an interface
+0
-0
ex-08-05 Explicit implementation
...arpSrcUpdate20/Chapter 8/ex-08-05 Explicit implementation
+0
-0
ex-08-06 References on value types
...pSrcUpdate20/Chapter 8/ex-08-06 References on value types
+0
-0
ex-08-07 MSIL code resulting from Example 8-6
...0/Chapter 8/ex-08-07 MSIL code resulting from Example 8-6
+0
-0
Makefile
ProgCSharpSrcUpdate20/Chapter 9/Makefile
+0
-0
ex-09-01 Working with an array
...SharpSrcUpdate20/Chapter 9/ex-09-01 Working with an array
+0
-0
ex-09-02 Using foreach
ProgCSharpSrcUpdate20/Chapter 9/ex-09-02 Using foreach
+0
-0
ex-09-03 params keyword
ProgCSharpSrcUpdate20/Chapter 9/ex-09-03 params keyword
+0
-0
ex-09-04 Rectangular arrays
ProgCSharpSrcUpdate20/Chapter 9/ex-09-04 Rectangular arrays
+0
-0
ex-09-05 multidimensional array
...harpSrcUpdate20/Chapter 9/ex-09-05 multidimensional array
+0
-0
ex-09-06 jagged array
ProgCSharpSrcUpdate20/Chapter 9/ex-09-06 jagged array
+0
-0
ex-09-07 Converting arrays
ProgCSharpSrcUpdate20/Chapter 9/ex-09-07 Converting arrays
+0
-0
ex-09-08 Array_Sort_Reverse
ProgCSharpSrcUpdate20/Chapter 9/ex-09-08 Array_Sort_Reverse
+0
-0
ex-09-09 simple indexer
ProgCSharpSrcUpdate20/Chapter 9/ex-09-09 simple indexer
+0
-0
ex-09-10 Overloading an index
...CSharpSrcUpdate20/Chapter 9/ex-09-10 Overloading an index
+0
-0
ex-09-11 Making a ListBox an enumerable class
...0/Chapter 9/ex-09-11 Making a ListBox an enumerable class
+0
-0
ex-09-11 Making a ListBox an enumerable class.cs
...hapter 9/ex-09-11 Making a ListBox an enumerable class.cs
+0
-0
ex-09-12 ArrayList
ProgCSharpSrcUpdate20/Chapter 9/ex-09-12 ArrayList
+0
-0
ex-09-13 Sorting an integer and an array
...date20/Chapter 9/ex-09-13 Sorting an integer and an array
+0
-0
ex-09-14 Sorting an array
ProgCSharpSrcUpdate20/Chapter 9/ex-09-14 Sorting an array
+0
-0
ex-09-15 queue
ProgCSharpSrcUpdate20/Chapter 9/ex-09-15 queue
+0
-0
ex-09-16 Stack
ProgCSharpSrcUpdate20/Chapter 9/ex-09-16 Stack
+0
-0
ex-09-17 Item property as offset operators
...te20/Chapter 9/ex-09-17 Item property as offset operators
+0
-0
ex-09-18 Keys and Values
ProgCSharpSrcUpdate20/Chapter 9/ex-09-18 Keys and Values
+0
-0
ex-09-19 IDictionaryEnumerator
...SharpSrcUpdate20/Chapter 9/ex-09-19 IDictionaryEnumerator
+0
-0
How To Use The Source Files.txt
ProgCSharpSrcUpdate20/How To Use The Source Files.txt
+0
-0
README.md
README.md
+0
-0
logo.png
logo.png
+0
-0
No files found.
ProgCSharpSrcUpdate20/Chapter 10/Makefile
0 → 100644
View file @
906d27b3
TARGETS
=
ex-10-01.exe ex-10-02.exe ex-10-03.exe ex-10-04.exe ex-10-05.exe ex-10-06.exe ex-10-07.exe ex-10-08.exe ex-10-09.exe
BROKEN
=
all
:
$(TARGETS)
BROKEN
:
$(BROKEN)
ex-10-01.exe
:
ex-10-01
csc /debug ex-10-01
ex-10-02.exe
:
ex-10-02
csc /debug ex-10-02
ex-10-03.exe
:
ex-10-03
csc /debug ex-10-03
ex-10-04.exe
:
ex-10-04
csc /debug ex-10-04
ex-10-05.exe
:
ex-10-05
csc /debug ex-10-05
ex-10-06.exe
:
ex-10-06
csc /debug ex-10-06
ex-10-07.exe
:
ex-10-07
csc /debug ex-10-07
ex-10-08.exe
:
ex-10-08
csc /debug ex-10-08
ex-10-09.exe
:
ex-10-09
csc /debug ex-10-09
test
:
all
for
%%d
in
(
$(TARGETS)
)
do
%%d
clean
:
-
del ex-10-01.pdb ex-10-02.pdb ex-10-03.pdb ex-10-04.pdb ex-10-05.pdb ex-10-06.pdb ex-10-07.pdb ex-10-08.pdb ex-10-09.pdb ex-10-01.exe ex-10-02.exe ex-10-03.exe ex-10-04.exe ex-10-05.exe ex-10-06.exe ex-10-07.exe ex-10-08.exe ex-10-09.exe
ProgCSharpSrcUpdate20/Chapter 10/ex-10-01 strings
0 → 100644
View file @
906d27b3
// Example 10-01: Working with strings
namespace Programming_CSharp
{
using System;
public class StringTester
{
static void Main( )
{
// create some strings to work with
string s1 = "abcd";
string s2 = "ABCD";
string s3 = @"Liberty Associates, Inc.
provides custom .NET development,
on-site Training and Consulting";
int result; // hold the results of comparisons
// compare two strings, case sensitive
result = string.Compare(s1, s2);
Console.WriteLine(
"compare s1: {0}, s2: {1}, result: {2}\n",
s1, s2, result);
// overloaded compare, takes boolean "ignore case"
//(true = ignore case)
result = string.Compare(s1,s2, true);
Console.WriteLine("compare insensitive\n");
Console.WriteLine("s4: {0}, s2: {1}, result: {2}\n",
s1, s2, result);
// concatenation method
string s6 = string.Concat(s1,s2);
Console.WriteLine(
"s6 concatenated from s1 and s2: {0}", s6);
// use the overloaded operator
string s7 = s1 + s2;
Console.WriteLine(
"s7 concatenated from s1 + s2: {0}", s7);
// the string copy method
string s8 = string.Copy(s7);
Console.WriteLine(
"s8 copied from s7: {0}", s8);
// use the overloaded operator
string s9 = s8;
Console.WriteLine("s9 = s8: {0}", s9);
// three ways to compare.
Console.WriteLine(
"\nDoes s9.Equals(s8)?: {0}",
s9.Equals(s8));
Console.WriteLine(
"Does Equals(s9,s8)?: {0}",
string.Equals(s9,s8));
Console.WriteLine(
"Does s9==s8?: {0}", s9 == s8);
// Two useful properties: the index and the length
Console.WriteLine(
"\nString s9 is {0} characters long. ",
s9.Length);
Console.WriteLine(
"The 5th character is {1}\n",
s9.Length, s9[4]);
// test whether a string ends with a set of characters
Console.WriteLine("s3:{0}\nEnds with Training?: {1}\n",
s3,
s3.EndsWith("Training") );
Console.WriteLine(
"Ends with Consulting?: {0}",
s3.EndsWith("Consulting"));
// return the index of the substring
Console.WriteLine(
"\nThe first occurrence of Training ");
Console.WriteLine ("in s3 is {0}\n",
s3.IndexOf("Training"));
// insert the word excellent before "training"
string s10 = s3.Insert(101,"excellent ");
Console.WriteLine("s10: {0}\n",s10);
// you can combine the two as follows:
string s11 = s3.Insert(s3.IndexOf("Training"),
"excellent ");
Console.WriteLine("s11: {0}\n",s11);
}
}
}
ProgCSharpSrcUpdate20/Chapter 10/ex-10-02 Substring
0 → 100644
View file @
906d27b3
// Example 10-02: Using the Substring() method
namespace Programming_CSharp
{
using System;
using System.Text;
public class StringTester
{
static void Main()
{
// create some strings to work with
string s1 = "One Two Three Four";
int ix;
// get the index of the last space
ix=s1.LastIndexOf(" ");
// get the last word.
string s2 = s1.Substring(ix+1);
// set s1 to the substring starting at 0
// and ending at ix (the start of the last word
// thus s1 has one two three
s1 = s1.Substring(0,ix);
// find the last space in s1 (after two)
ix = s1.LastIndexOf(" ");
// set s3 to the substring starting at
// ix, the space after "two" plus one more
// thus s3 = "three"
string s3 = s1.Substring(ix+1);
// reset s1 to the substring starting at 0
// and ending at ix, thus the string "one two"
s1 = s1.Substring(0,ix);
// reset ix to the space between
// "one" and "two"
ix = s1.LastIndexOf(" ");
// set s4 to the substring starting one
// space after ix, thus the substring "two"
string s4 = s1.Substring(ix+1);
// reset s1 to the substring starting at 0
// and ending at ix, thus "one"
s1 = s1.Substring(0,ix);
// set ix to the last space, but there is
// none so ix now = -1
ix = s1.LastIndexOf(" ");
// set s5 to the substring at one past
// the last space. there was no last space
// so this sets s5 to the substring starting
// at zero
string s5 = s1.Substring(ix+1);
Console.WriteLine ("s2: {0}\ns3: {1}",s2,s3);
Console.WriteLine ("s4: {0}\ns5: {1}\n",s4,s5);
Console.WriteLine ("s1: {0}\n",s1);
}
}
}
ProgCSharpSrcUpdate20/Chapter 10/ex-10-03 Split
0 → 100644
View file @
906d27b3
// Example 10-03: Using the Split() method
namespace Programming_CSharp
{
using System;
using System.Text;
public class StringTester
{
static void Main()
{
// create some strings to work with
string s1 = "One,Two,Three Liberty Associates, Inc.";
// constants for the space and comma characters
const char Space = ' ';
const char Comma = ',';
// array of delimiters to split the sentence with
char[] delimiters = new char[]
{
Space,
Comma
};
string output = "";
int ctr = 1;
// split the string and then iterate over the
// resulting array of strings
foreach (string subString in s1.Split(delimiters))
{
output += ctr++;
output += ": ";
output += subString;
output += "\n";
}
Console.WriteLine(output);
}
}
}
ProgCSharpSrcUpdate20/Chapter 10/ex-10-04 StringBuilder
0 → 100644
View file @
906d27b3
// Example 10-04: Using a StringBuilder
namespace Programming_CSharp
{
using System;
using System.Text;
public class StringTester
{
static void Main()
{
// create some strings to work with
string s1 = "One,Two,Three Liberty Associates, Inc.";
// constants for the space and comma characters
const char Space = ' ';
const char Comma = ',';
// array of delimiters to split the sentence with
char[] delimiters = new char[]
{
Space,
Comma
};
// use a StringBuilder class to build the
// output string
StringBuilder output = new StringBuilder();
int ctr = 1;
// split the string and then iterate over the
// resulting array of strings
foreach (string subString in s1.Split(delimiters))
{
// AppendFormat appends a formatted string
output.AppendFormat("{0}: {1}\n",ctr++,subString);
}
Console.WriteLine(output);
}
}
}
ProgCSharpSrcUpdate20/Chapter 10/ex-10-05 Regex
0 → 100644
View file @
906d27b3
// Example 10-05: Using the Regex class for regular expressions
namespace Programming_CSharp
{
using System;
using System.Text;
using System.Text.RegularExpressions;
public class Tester
{
static void Main( )
{
string s1 =
"One,Two,Three Liberty Associates, Inc.";
Regex theRegex = new Regex(" |, |,");
StringBuilder sBuilder = new StringBuilder( );
int id = 1;
foreach (string subString in theRegex.Split(s1))
{
sBuilder.AppendFormat(
"{0}: {1}\n", id++, subString);
}
Console.WriteLine("{0}", sBuilder);
}
}
}
ProgCSharpSrcUpdate20/Chapter 10/ex-10-06 static Regex
0 → 100644
View file @
906d27b3
// Example 10-06: Using static Regex.Split()
namespace Programming_CSharp
{
using System;
using System.Text;
using System.Text.RegularExpressions;
public class Tester
{
static void Main( )
{
string s1 =
"One,Two,Three Liberty Associates, Inc.";
StringBuilder sBuilder = new StringBuilder( );
int id = 1;
foreach (string subStr in Regex.Split(s1," |, |,"))
{
sBuilder.AppendFormat("{0}: {1}\n", id++, subStr);
}
Console.WriteLine("{0}", sBuilder);
}
}
}
ProgCSharpSrcUpdate20/Chapter 10/ex-10-07 MatchCollection and Match
0 → 100644
View file @
906d27b3
// Example 10-07: Using MatchCollection and Match
namespace Programming_CSharp
{
using System;
using System.Text.RegularExpressions;
class Test
{
public static void Main()
{
string string1 = "This is a test string";
// find any nonwhitespace followed by whitespace
Regex theReg = new Regex(@"(\S+)\s");
// get the collection of matches
MatchCollection theMatches =
theReg.Matches(string1);
// iterate through the collection
foreach (Match theMatch in theMatches)
{
Console.WriteLine(
"theMatch.Length: {0}", theMatch.Length);
if (theMatch.Length != 0)
{
Console.WriteLine("theMatch: {0}",
theMatch.ToString());
}
}
}
}
}
ProgCSharpSrcUpdate20/Chapter 10/ex-10-08 Group class
0 → 100644
View file @
906d27b3
// Example 10-08: Using the Group class
namespace Programming_CSharp
{
using System;
using System.Text.RegularExpressions;
class Test
{
public static void Main()
{
string string1 = "04:03:27 127.0.0.0 LibertyAssociates.com";
// group time = one or more digits or colons followed by space
Regex theReg = new Regex(@"(?<time>(\d|\:)+)\s" +
// ip address = one or more digits or dots followed by space
@"(?<ip>(\d|\.)+)\s" +
// site = one or more characters
@"(?<site>\S+)");
// get the collection of matches
MatchCollection theMatches = theReg.Matches(string1);
// iterate through the collection
foreach (Match theMatch in theMatches)
{
if (theMatch.Length != 0)
{
Console.WriteLine("\ntheMatch: {0}",
theMatch.ToString());
Console.WriteLine("time: {0}",
theMatch.Groups["time"]);
Console.WriteLine("ip: {0}",
theMatch.Groups["ip"]);
Console.WriteLine("site: {0}",
theMatch.Groups["site"]);
}
}
}
}
}
ProgCSharpSrcUpdate20/Chapter 10/ex-10-09 capture collection
0 → 100644
View file @
906d27b3
// Example 10-09: Examining the capture collection
namespace Programming_CSharp
{
using System;
using System.Text.RegularExpressions;
class Test
{
public static void Main()
{
// the string to parse
// note that names appear in both
// searchable positions
string string1 =
"04:03:27 Jesse 0.0.0.127 Liberty ";
// regular expression which groups company twice
Regex theReg = new Regex(@"(?<time>(\d|\:)+)\s" +
@"(?<company>\S+)\s" +
@"(?<ip>(\d|\.)+)\s" +
@"(?<company>\S+)\s");
// get the collection of matches
MatchCollection theMatches =
theReg.Matches(string1);
// iterate through the collection
foreach (Match theMatch in theMatches)
{
if (theMatch.Length != 0)
{
Console.WriteLine("theMatch: {0}",
theMatch.ToString());
Console.WriteLine("time: {0}",
theMatch.Groups["time"]);
Console.WriteLine("ip: {0}",
theMatch.Groups["ip"]);
Console.WriteLine("Company: {0}",
theMatch.Groups["company"]);
// iterate over the captures collection
// in the company group within the
// groups collection in the match
foreach (Capture cap in
theMatch.Groups["company"].Captures)
{
Console.WriteLine("cap: {0}",cap.ToString());
}
}
}
}
}
}
ProgCSharpSrcUpdate20/Chapter 11/Makefile
0 → 100644
View file @
906d27b3
TARGETS
=
ex-11-01.exe ex-11-02.exe ex-11-03.exe ex-11-04.exe ex-11-05.exe ex-11-06.exe ex-11-07.exe ex-11-08.exe
BROKEN
=
all
:
$(TARGETS)
BROKEN
:
$(BROKEN)
ex-11-01.exe
:
ex-11-01
csc /debug ex-11-01
ex-11-02.exe
:
ex-11-02
csc /debug ex-11-02
ex-11-03.exe
:
ex-11-03
csc /debug ex-11-03
ex-11-04.exe
:
ex-11-04
csc /debug ex-11-04
ex-11-05.exe
:
ex-11-05
csc /debug ex-11-05
ex-11-06.exe
:
ex-11-06
csc /debug ex-11-06
ex-11-07.exe
:
ex-11-07
csc /debug ex-11-07
ex-11-08.exe
:
ex-11-08
csc /debug ex-11-08
test
:
all
for
%%d
in
(
$(TARGETS)
)
do
%%d
clean
:
-
del ex-11-01.pdb ex-11-02.pdb ex-11-03.pdb ex-11-04.pdb ex-11-05.pdb ex-11-06.pdb ex-11-07.pdb ex-11-08.pdb ex-11-01.exe ex-11-02.exe ex-11-03.exe ex-11-04.exe ex-11-05.exe ex-11-06.exe ex-11-07.exe ex-11-08.exe
ProgCSharpSrcUpdate20/Chapter 11/ex-11-01 Throwing an exception
0 → 100644
View file @
906d27b3
// Example 11-01: Throwing an exception
// Caution: throws an unhandled exception!
namespace Programming_CSharp
{
using System;
public class Test
{
public static void Main()
{
Console.WriteLine("Enter Main...");
Test t = new Test();
t.Func1();
Console.WriteLine("Exit Main...");
}
public void Func1()
{
Console.WriteLine("Enter Func1...");
Func2();
Console.WriteLine("Exit Func1...");
}
public void Func2()
{
Console.WriteLine("Enter Func2...");
throw new System.Exception();
Console.WriteLine("Exit Func2...");
}
}
}
ProgCSharpSrcUpdate20/Chapter 11/ex-11-02 Catching an exception
0 → 100644
View file @
906d27b3
// Example 11-02: Catching an exception
namespace Programming_CSharp
{
using System;
public class Test
{
public static void Main()
{
Console.WriteLine("Enter Main...");
Test t = new Test();
t.Func1();
Console.WriteLine("Exit Main...");
}
public void Func1()
{
Console.WriteLine("Enter Func1...");
Func2();
Console.WriteLine("Exit Func1...");
}
public void Func2()
{
Console.WriteLine("Enter Func2...");
try
{
Console.WriteLine("Entering try block...");
throw new System.Exception();
Console.WriteLine("Exiting try block...");
}
catch
{
Console.WriteLine(
"Exception caught and handled.");
}
Console.WriteLine("Exit Func2...");
}
}
}
ProgCSharpSrcUpdate20/Chapter 11/ex-11-03 Catch in a calling function
0 → 100644
View file @
906d27b3
// Example 11-03: Catch in a calling function
namespace Programming_CSharp
{
using System;
public class Test
{
public static void Main()
{
Console.WriteLine("Enter Main...");
Test t = new Test();
t.Func1();
Console.WriteLine("Exit Main...");
}
public void Func1()
{
Console.WriteLine("Enter Func1...");
try
{
Console.WriteLine("Entering try block...");
Func2();
Console.WriteLine("Exiting try block...");
}
catch
{
Console.WriteLine(
"Exception caught and handled.");
}
Console.WriteLine("Exit Func1...");
}
public void Func2()
{
Console.WriteLine("Enter Func2...");
throw new System.Exception();
Console.WriteLine("Exit Func2...");
}
}
}
ProgCSharpSrcUpdate20/Chapter 11/ex-11-04 Specifying the exception
0 → 100644
View file @
906d27b3
// Example 11-04: Specifying the exception to catch
namespace Programming_CSharp
{
using System;
public class Test
{
public static void Main()
{