Home > Store

C# Primer: A Practical Approach

Register your product to gain access to bonus material or receive a coupon.

C# Primer: A Practical Approach


  • Sorry, this book is no longer in print.
Not for Sale



Highlights include:

  • Covers fundamentals such as namespaces, exception handling, and unified type system.
  • Presents a wide-ranging tour of the .NET class library, introducing ADO.NET and establishing database connections and the use of XML.
  • Provides XML programming using the firehose and DOM parser models, XSLT, XPATH, and schemas.
  • Focuses on ASP.NET Web Form Designer, walking through the page life-cycle and caching, and providing a large number of examples.
  • Introduces .NET Common Language Runtime (CLR).
C# PRIMER provides a solid foundation to build upon and a refreshingly unbiased voice on Microsoft's vehicle to effective and efficient Web-based programming.


  • Copyright 2002
  • Dimensions: 7-3/8" x 9-1/4"
  • Edition: 1st
  • Book
  • ISBN-10: 0-201-72955-5
  • ISBN-13: 978-0-201-72955-9

Developers have long sought a language that combined the simplicity of Visual Basic with the power and flexibility of C++. For them, Microsoft has created C# -- systematically incorporating features intended to simplify the development of next-generation components and services. Now, one of the world's leading C++ experts and authors presents a start-to-finish, practical introduction developers need to leverage their existing skills with Microsoft's breakthrough new language. Stanley B. Lippman -- who was on the ground floor of the worldwide C++ revolution -- focuses on C# as a tool for building sophisticated COM+ components and Web services. Using extensive program examples, Lippman walks step-by-step through the fundamentals of C# syntax, classes, and object-oriented programming; inheritance, interfaces, delegates, events, attributes, reflection, exception handling, namespaces, assemblies, and more. The book concludes with a detailed chapter on interoperability between C# and legacy code. Appendices include a concise C# handbook and a quick tour of the new Visual Studio.NET development environment. For all intermediate programmers and developers who want to leverage their C, C++, or Java skills with Microsoft's new C#.


Source Code

Click below for Source Code related to this title:


Related Article

Efficient C++ Programming

Web Resources

Click below for Web Resources related to this title:
Author Web Site


Click below for Interview related to this title:

Sample Content

Online Sample Chapters

Hello, C#

The Standard Template Library: Generic Programming

Downloadable Sample Chapter

Click below for Sample Chapter related to this title:

Table of Contents


1. Hello, C.

A First C Program.


Alternative Forms of the Main Function.

Making a Statement.

Opening a Text File for Read and Write.

Formatting Output.

The string Type.

Local Objects.

A Value and Reference Types.

The C Array.

The new expression.

Garbage Collection.

Dynamic Arrays: The ArrayList Collection Class.

The Unified Type System.

Shadow Boxing.

Unboxing Leaves Us Downcast.

Jagged Arrays.

The Hashtable Container.

Exception Handling.

A Basic Language Handbook.


Built-in Numeric Types.

Arithmetic, Relational, and Conditional Operators.

Operator Precedence.


2. Class Design.

Our First Independent Class.

Opening a New Visual Studio Project.

Declaring Data Members.



Member Initialization.

The Class Constructor.

The Implicit this Reference.

static Class Members.

const and readonly Data Members.

The enum Value Type.

The delegate Type.

Function Parameter Semantics.

Function Overloading.

Pass by Value.

Pass by Reference: The ref Parameter.

Pass by Reference: The out Parameter.

Variable-Length Parameter Lists.

Operator Overloading.

Conversion Operators.

The Class Destructor.

The struct Value Type.

3. Object-Oriented Programming.

Object-Oriented Programming Concepts.

Supporting a Polymorphic Query Language.

Designing a Class Hierarchy.

Object Lessons.

Designing an Abstract Base Class.

Declaring an Abstract Base Class.

Static Members of an Abstract Base Class.

A Hybrid Abstract Base Class.

The Single-Inheritance Object Model.

How Is a Hybrid Abstract Class Different?

Defining a Derived Class.

Overriding the Inherited Virtual Interface.

Overriding the Virtual Object Methods.

Member Access: The new and base Modifiers.

Accessibility versus Visibility.

Encapsulating Base-Class Access.

Sealing a Class.

The Exception Class Hierarchy.

4. Interface Inheritance.

Implementing a System Interface: IComparable.

Accessing an Existing Interface.

Defining an Interface.

Implementing Our Interface: Proof of Concept.

Integrating Our Interface within the System Framework.

Explicit Interface Member Implementations.

Inherited Interface Members.

Overloaded, Hidden, or Ambiguous?

Mastering Copy Semantics: Icloneable.

Mastering Finalize Semantics: Idisposable.

BitVector: Extension through Composition.

5. Exploring the System Namespace.

Supporting the Fundamental Types.

The Array Is a System.Array.

Querying the Environment.

The Environment Class.

Accessing All the Environment Variables.

The Process Class.

Finding the Logical Drives.


Handling File Extensions: The Path Class.

Manipulating Directories.

Manipulating Files.

Reading and Writing Files.

A System Miscellany.

The System.Collections.Stack Container.

The System.Diagnostics.TraceListener Class.


The DateTime Class.

Regular Expressions.


The Web Request/Response Model.


The Server-Side TcpListener.

The Client-Side TcpClient.

System.Data (ADO.NET).

The Database Tables.

Opening the Database: Selecting a Data Provider.

Navigating the DataTable.

Setting Up the DataRelation.

Selection and Expressions.


Getting XML Out of Our Programs.

XmlTextReader: The Firehose.

Document Object Model.



6. Windows Forms Designer.

Our First Windows Forms Program.

Building the GUI.

Implementing the Event Callback Routines.

Implementing a TextBox Event.

Implementing the Button Events: OK.

Implementing the Button Events: Quit.

Inspecting and Generating Control Events.

Labels Are Programmable.

Implementing the MessageBox Popup Dialog.

The ListBox for Unformatted Output.

Exploring the File Dialog.

A Pocketful of Buttons.

Serving Up Menus.

The DataGrid Control.

Adding a PictureBox Control.

7. ASP.NET and Web Forms Designer.

Our First Web Forms Program.

Opening an ASP.NET Web Application Project.

Modifying the Document Properties.

Adding Controls to the Document: Label.

Adding Additional Pages to a Project.

The HyperLink Control: Linking to Other Pages.

The DataGrid Control.

Understanding the Page Event Life Cycle.

The Data Provider.

Web State Management.

Adding a TextBox Control.

Adding an ImageButton Control.

Adding a ListBox Control.

Managing State: Class Members.

Managing State: the Session Object.

Managing State: the Application Object.

Validation Controls.

Adding a DropDownList Control.

Adding a Group of RadioButton Controls.

Adding a CheckBoxList Controls.

Adding Validators to a Control.

Adding a Calendar Control.

Adding an Image Control.

Programming Web Server Controls.

8. The Common Language Runtime.


Runtime Type Reflection.

Modifying the Retrieval through BindingFlags.

Invoking a Method during Runtime.

Delegating the Test to Reflection.


The Intrinsic Conditional Attribute.

The Intrinsic Serializable Attribute.

The Intrinsic Dllimport Attribute.

The Intrinsic Conditional Attribute.

The Intrinsic Serializable Attribute.

The Intrinsic Dllimport Attribute.

Implementing Our Own Attribute Class.

Positional and Named Parameters.


Runtime Discovery of Attributes Using Reflection.

The Intermediate Language.

Examining the Intermediate Language.

The ildasm Tool.

Index. 0201729555T11292001


C# is a new language invented at Microsoft and introduced with Visual Studio.NET. More than a million lines of C# code already have gone into the implementation of the .NET class framework. This book covers the C# language and its use in programming the .NET class framework, illustrating application domains such as ASP.NET and XML.

My general strategy in presenting the material is to introduce a programming task and then walk through one or two implementations, introducing language features or aspects of the class framework as they prove useful. The goal is to demonstrate how to use the language and class framework to solve problems rather than simply to list language features and the class framework API.

Learning C# is a two-step process: learning the details of the C# language and then becoming familiar with the .NET class framework. This two-step process is reflected in the organization of this text.

In the first step we walk through the language--both its mechanisms, such as class and interface inheritance and delegates, and its underlying concepts, such as its unified type system, reference versus value types, boxing, and so on. This step is covered in the first four chapters.

The second step is to become familiar with the .NET class framework, in particular with Windows and Web programming and the support for XML. This is the focus of the second half of the book.

Working your way through the text should jump-start your C# programming skills. In addition, you'll become familiar with a good swatch of the .NET class framework. All the program code is available for download at my company's Web site www.objectwrite.com.

Mail can be sent to me directly at slippman@objectwrite.com.

Organization of the Book

The book is organized into eight relatively long chapters. The first four chapters focus on the C# language, looking at the built-in language features, the class mechanism, class inheritance, and interface inheritance. The second four chapters explore the various library domains supported within the .NET class framework.

Chapter 1 covers the basic language, as well as some of the fundamental classes provided within the class framework. The discussion is driven by the design of a small program. Concepts such as namespaces, exception handling, and the unified type system are introduced.

Chapter 2 covers the fundamentals of building classes. We look at access permission, distinguish between const and readonly members, and cover specialized methods such as indexers and properties. We walk through the different strategies of member initialization, as well as the rules for operator overloading and conversion operators. We look at the delegate type, which serves as a kind of universal pointer to a function.

Chapters 3 and 4 cover, in turn, class and interface inheritance. Class inheritance allows us to define a family of specialized types that override a generic interface, such as an abstract WebRequest base class and a protocol-specific HttpWebRequest subtype. Interface inheritance, on the other hand, allows us to provide a common service or shared attribute for otherwise unrelated types. For example, the IDisposable interface frees resources. Classes holding database connections or window handles are both likely to implement IDisposable, although they are otherwise unrelated.

Chapter 5 provides a wide-ranging tour of the .NET class library. We look at input and output, including file and directory manipulation, regular expressions, sockets and thread programming, the WebRequest and WebResponse class hierarchies, a brief introduction to ADO.NET and establishing database connections, and the use of XML.

Chapters 6 and 7 cover, in turn, drag-and-drop Windows Forms and Web Forms development. Chapter 7 focuses on ASP.NET, and the Web page life cycle. Both chapters provide lots of examples of using the prebuilt controls and attaching event handlers for user interaction.

The final chapter provides a programmer's introduction to the .NET Common Language Runtime. It focuses on assemblies, type reflection, and attributes, and concludes with a brief look at the underlying intermediate language that is the compilation target of all .NET languages.

Written for Programmers

The book does not assume that you know C++, Visual Basic, or Java. But it does assume that you have programmed in some language. So, for example, I don't assume that you know the exact syntax of the C# foreach loop statement, but I do assume that you know what a loop is. Although I will illustrate how to invoke a function in C#, I assume you know what I mean when I say we "invoke a function." This text does not require previous knowledge of object-oriented programming or of the earlier versions of ASP and ADO.

Some people--some very bright people--argue that under .NET, the programming language is secondary to the underlying Common Language Runtime (CLR) upon which the languages float like the continents on tectonic plates. I don't agree. Language is how we express ourselves, and the choice of one's language affects the design of our programs. The underlying assumption of this book is that C# is the preferred language for .NET programming.

The book is organized into eight relatively long chapters. The first set of four chapters focuses on the C# language, looking at the built-in language features, the class mechanism, class inheritance, and interface inheritance. The second set of four chapters explores the various library domains supported within the .NET class framework, such as regular expressions, threading, sockets, Windows Forms, ASP.NET, and the Common Language Runtime.

Lexical Conventions

Type names, objects, and keywords are set off in Courier font, as in int, a predefined language type; Console, a class defined in the framework; maxCount, an object defined either as a data member or as a local object within a function; and foreach, one of the predefined loop statements. Function names are followed by an empty pair of parentheses, as in WriteLine(). The first introduction of a concept, such as garbage collection or data encapsulation, is highlighted in italics. These conventions are intended to make the text more readable.


The richest documentation that you will be returning to time and again is the Visual Studio.NET documentation. The .NET framework reference is essential to doing any sort of C#/.NET programming.

Another rich source of information about .NET consists of the featured articles and columns in the MSDN Magazine. I'm always impressed by what I find in each issue. You can find it online at http://msdn.microsoft.com/msdnmag.

The DOTNET mailing list sponsored by DevelopMentor is a rich source of information. You can subscribe to it at http://discuss.develop.com.

Anything Jeffrey Richter, Don Box, Aaron Skonnard, or Jeff Prosise writes about .NET (or XML in Aaron's case) should be considered essential reading. Currently, most of their writing has appeared only as articles in MSDN Magazine.Here is the collection of books that I have referenced or found helpful:

  • Active Server Pages+, by Richard Anderson, Alex Homer, Rob Howard, and Dave Sussman, Wrox Press, Birmingham, England, 2000.
  • C# Essentials, by Ben Albahari, Peter Drayton, and Brad Merrill, O'Reilly, Cambridge, MA, 2001.
  • C# Programming, by Burton Harvey, Simon Robinson, Julian Templeman, and Karli Watson, Wrox Press, Birmingham, England, 2000.
  • Essential XML: Beyond Markup, by Don Box, Aaron Skonnard, and John Lam, Addison-Wesley, Boston, 2000.
  • Microsoft C# Language Specifications, Microsoft Press, Redmond, WA, 2001.
  • A Programmer's Introduction to C#, 2nd Edition, by Eric Gunnerson, Apress, Berkeley, CA, 2001.
Stanley Lippman
Los Angeles
November 18, 2001




! (logical not), 53, 55
!= (inequality operator), 53, 55
% (remainder), 52, 55
%= (compound remainder), 54
& (bitwise and), 53, 55
&& (logical and), 53, 55
--(decrement), 52, 54
-(subtraction), 52, 55
* (multiplication), 52, 55
*= (compound multiply), 54
+ (addition), 52, 55
++ (increment), 52, 54
+= (compound add), 54
. (scope), 4
/ (division), 52, 55
// (comment), 2
/= (compound divide), 54
<= (less than equal), 53, 55
= (assignment), 54, 55
-= (compound minus), 54
== (equality operator), 53, 55
> (greater than), 53, 55
>= (greater than equal), 53, 55
?: (conditional operator), 53
@ (prefix), 17, 48
| (bitwise or), 53, 55
|| (logical or), 53, 55


arithmetic operators,
see expressions
array, 29-30
as System.Array, 200-203
initialization, 31, 40
jagged, 39-40
jagged vs. multidimensional, 39
multidimensional, 29
ArrayList, see System.Collections
as operator, 38
ASP.NET, 315-348
Calendar, 344
CheckBoxList, 338-340
DataGrid, 321
Document, 318-319
DropDownList, 335, 336
HyperLink, 321
Image, 345
ImageButton, 329
Label, 319
ListBox, 329
programming, 345-348
RadioButtonList, 337
TextBox, 328
database connection, 325-326
event handling, 323
change events, 323
click events, 323
HttpApplication class, 333
AutoPostBack, 323
event life cycle, 323-325
IsPostBack, 324
linking to, 321
Page_Load(), 324
post back, 323
round-trip, 323
adding a page, 320
Design view, 317
FlowLayout, 319
GridLayout, 319
HTML view, 317
opening a project, 316-319
Properties window, 316, 318
Solution Explorer, 318
Toolbox window, 316, 319
state management, 326-328
Application Object, 333-334
instance members, 331-332
Session Object, 332-333
Validator controls, 334, 340-343
CompareValidator, 340
CustomValidator, 341
RangeValidator, 340
RegularExpressionValidator, 341
RequiredFieldValidator, 340
ValidationSummary, 341
assemblies, 349-353, 366
AppDomain, 350
Assembly, 350
Attributes, 367-378
AttributeUsage, 373, 376
custom Attributes, 372-376
GetCustomAttributes(), 377
intrinsic, 367-372
CLSCompliant, 379
Conditional, 367-369
DllImport, 370-372
NonSerialized, 369-370
Serializable, 369-370
multiple Attributes, 375
named parameters, 375
position parameters, 375
runtime discovery, 376-378
See also reflection


base keyword
see class constructor
see object-oriented
bool, see types
boxing 36-37
See also unboxing
break, see statement


capacity, 34
cast, see conversion
catch, see exception handling
class, 59-116
access level, 62
constructor, 73-76
access level, 76
base, 143
base vs. this, 144
new expression, 74
static, 80, 81, 366
this keyword, 75
when to use, 73
conversion operators, 110-112, 196
explicit, 111
implicit, 110
copy semantics
see System.ICloneable
data member, 66-67
access level, 67, 68
const, 81-83
readonly, 81-83
readonly vs. const, 83
declaration order, 62
destructor, 113
deterministic finalization
see System.IDisposable
domain abstraction, 2
independent abstraction, 59-63
indexer, 69-72
initialization, 72-76
default, 72
explicit, 72
three strategies, 76
See also constructor
member function, 60-62
access level, 61
arguments vs. parameters, 93
overload resolution, 100-103
overloading, 99-103
parameter list, 61, 92-99
pass by reference
out, 97
ref, 96
pass by value, 94-96
return type, 61
signature, 61
variable-length parameter list, 103-106
operator overloading, 107-110
binary operators, 110
invocation, 107
compound assignment, 108
unary operators, 109
properties, 67-69
get read access, 69
set write access, 69
public interface, 59
reference type, 29
sealing, 153
static member, 79-81
access usage, 80
static vs. instance, 79
in constructor, 75
as reference, 76-78
See also object-oriented command-line arguments, 11
comment, 2
Common Language
Runtime (CLR), 349
Specification (CLS), 378
const, see class data member
continue, see statement
cast, 37
derived to base class, 127
explicit, 37, 42, 49
foreach vs. for loop, 39
implicit, 101
operators, see class
overload resolution, 102
smaller than int, 49
standard implicit, 101
conversion operators, see class
copy constructor
see System.ICloneable


data member, see class
database, see System.Data
decimal, see types
declaration space, see scope
deep copy, 28, 186
definite assignment, 25
delegate type, 86-92, 364-367
declaration, 87
Delegate interface, 92
invocation, 90
object reference, 91
reference type, 88
set to instance method, 88
set to multiple methods, 90
set to static method, 88
single vs. multiple methods, 87
destructor, see class
deterministic finalization
see System.IDisposeable
dictionary, see
double, see types
do-while, see statement
dynamic binding, 120, 128


entry point, see Main()
enum type, 83-86
enumerator values, 84
relation to int, 84
underlying type, 85
environment variables
see System.Environment
exception handling, 44-47
catch clause, 44-45
catch resolution, 157
defining our own exceptions, 156
Exception class hierarchy, 45, 154-158
exception safety, 189
finally clause, 47
handling the exception, 46
inner exception, 155
non-resumption ,46
throw expression, 44, 45
try block, 45 expressions
arithmetic, 51
checked, 52
conditional, 51
exceptions, 52
integral promotion, 50
overflow, 172
relational, 51
unchecked, 52


Fantasia 2000, 228
files, see System.IO
finally, see exception handling
float, see types
for, see statement
foreach, see statement
Forms Designer, see Windows
freeing unmanaged resources
see System.IDisposable
fully qualified name, 5
See also namespaces
function overloading
see class member function
function, see class


garbage collection, 32-33
resource cleanup,
see System.IDisposable
See also class destructor


HashTable, see


identifier, see name
if, see statement
ildasm tool, 381-383
indexer, see class
information hiding, see class 68
see interface inheritance
see object-oriented
initialization, 24-25, 27
array, 31
input/output, see System.IO
int, see types
integral promotion, 50
interface inheritance, 159-197
access existing interface, 163-166
allowed member types, 167
contrast to abstract base class, 159
defining an interface, 166-180
determining the exceptions, 173-174
explicit interface member, 178-180
implement all members, 168
implement interface, 160-163
inheritance and visibility, 180-185
inheriting from an interface, 168-174
integration with framework, 174
master copy semantics, 185-187
master finalize semantics, 187-190
resolving ambiguity, 184
simplest definition, 167
virtual methods, 181-183
See also object-oriented
intermediate language, 378-383
interoperability, 370
is operator, 38
iterator, 175
See also System.IEnumerator


keywords, 47


lifetime, 36
See also garbage collection
literals, see types
local object, see scope
lock, 241, See also System.Threading
long, see types


Main(), 2, 10-11
command-line arguments, 11
program entry point, 2
program exit status, 11
return value, 11
managed heap, 28, 32
See also garbage collection
map, see
member function, see class
metadata, see reflection


fully qualified, 5, 8
inheritance resolution, 148
local resolution, 26
name collision, 6
naming rules, 6, 48
resolution based on visiblity, 150
visibility of name, 6
namespaces, 3, 6-10
definition, 8
name collision, 7
naming conventions, 10
visibility rules, 8
native method call, 370
See also Attributes, DllImport
new expression, 28, 30-32, 36
new specifier, 149, 181
numeric types, see types


object, 35-38
heterogeneous parameter list, 105
universal assignment, 130
See also System.Object
See also universal type system
object-oriented, 117-158
abstract base class, 118, 132-139
abstract keyword, 135
abstract virtual function, 134
definition, 133
hybrid design, 138-139
abstract derived class, 135
composition, 194
copy semantics
see System.ICloneable
derived class, 118, 143-152
abstract, 143
access hidden member, 135
base constructor, 144
constructor, 143
member access, 147-152
member resolution, 148
new specifier, 149
virtual function, 145-146
deterministic finalization
see System.IDisposable
hybrid base class, 141-142
implementation inheritance, 142
implicit conversion, 127
inheritance hierarchy, 118, 126
member resolution, 150
methods hidden by signature, 184
polymorphism, 118-120
refactoring, 136
single inheritance, 140-141
static member, 137-138
type/subtype, 126
virtual function, 128, 134
abstract, 134-135
covariant return type, 145
override, 145
static invocation, 153
virtual indexers, 136
virtual properties, 136
See also interface inheritance
See also class
precedence, 18, 54-55
overloading, see class
formatted output, 20
See also Console
See also System.IO
functions, see class
operators, see class
subscript, see class indexer


params keyword, see
class member functions
pass by reference, see
class member functions
pass by value, see
class member functions
pointer to function, see delegate
polymorphism, see object-oriented
program entry point, see Main()
properties, see class


readonly, see class data member
reference counting, 32
reference types, 28-29, 36
pass by value, 94-96
See also array
See also class
See also delegate
reflection, 353-367
See also System.Reflection 353
See also System.Type
regular expressions, see
relational operators, see expressions
return, see statement
runtime object creation
see System.Activator
runtime type discovery
see System.Reflection
runtime type query
as operator, 38
is operator, 38


global, 6
local, 24-27
lifetime, 36
order dependent, 26
uninitialized, 24
scope operator (.), 4
sealing, see class
serialization, 370
shallow copy, 28, 32, 36, 96, 186
SOAP, 281
sockets, see System.Net.Sockets
Sqrt(), see System.Math
statement, 55-57
break, 20
continue, 19
do-while, 25, 56
for, 22, 56
foreach, 13, 39, 56
if, 12, 56
if-else, 13
return, 12-13
switch, 14-16, 57
while, 56
statement block, 12
static binding, 119, 128
string, see types
struct, 113-116
implicit default constructor, 114
initialization, 115
new expression, 114
non-garbage collected, 114
performance, 116
value type, 29
switch, see statement
System, 199-281
Activator, 363
CreateInstance(), 363, 367
Array, 200-203
BinarySearch(), 203
Clear(), 202
Copy(), 202
CopyTo(), 201
GetLength(), 201
IndexOf(), 202, 203
Sort(), 206
Attribute, see Attributes
Console, 2
ReadLine(), 24
Write(), 2
WriteLine(), 2
DateTime, 208, 226-227
Bitmap, 312
Graphics, 314
Environment, 204-207
GetLogicalDirves(), 209
OSVersion, 205
ICloneable, 185-187, 195
IComparable, 160-163, 164-166
IDisposable, 187-190
IEnumerable, 174
IEnumerator, 175-178
Math, 225
namespace introduction, 3
OperatingSystem, 205
PlatformID, 205
TimeSpan, 208
Windows.Forms, see Windows
ArrayList, 33-35, 160
BitArray, 190-197
Hashtable, 41-43
ICollection, 194
IDictionary, 43
Queue, 223
Stack, 221-223
System.Data, 249-259
connection string, 252, 253, 325
DataRelation, 251, 257-258
DataSet, 253
DataSet/XML interop, 260
DataTable, 254-257
Select(), 258-259
OleDbCommand, 253
OleDbConnection, 253
OleDbDataAdapter, 253
selection string, 325
SqlClient, 325-326
SqlCommand, 326
SqlConnection, 325
SqlDataAdapter, 326
Process, 207-208
GetCurrentProcess(), 207
GetProcesses(), 207
TraceListener, 223-225
System.IO, 17-19, 209-221
Directory, 209, 210, 212-215
Exists(), 210
GetDirectories(), 213
DirectoryInfo, 209, 212-215
CreateFile(), 213
CreateSubdirectory(), 213
GetFiles(), 213
File, 44, 210, 215-221
Exists(), 210
OpenRead(), 218
OpenWrite(), 218
file read and write, 216-221
FileAccess, 219
FileInfo, 209, 215-221
AppendText(), 217
CreateText(), 217
OpenText(), 217
FileMode, 218
FileShare, 219
Path, 209, 210-212
ChangeExtension(), 211
DirectorySeparatorChar, 214
GetExtension(), 211
Stream, 218-221, 244
Read(), 218
Seek, 219-221
Write(), 218
StreamReader, 17-18, 216-217
StreamWriter, 17-18, 216-217
See also System.Console
System.Net, 241-249
HttpWebRequest, 243
Sockets, 245-249
NetworkStream, 245, 248
Socket, 247
Connected, 247
Receive(), 247
Send(), 248
TcpClient, 245, 248-249
GetStream(), 248
TcpListener, 245, 246-248
AcceptSocket(), 247
Start(), 246
Uri, 242
UriBuilder, 243
WebRequest, 243
Create(), 243
GetResponse(), 244
WebResponse, 244
System.Object, 130-132
Equals(), 130, 131, 147
GetType(), 131
implicit base class, 131
overriding methods, 146-147
ToString(), 130, 131, 146
Assembly, 350
BindingFlags enum, 358-362
ConstructorInfo, 354, 361
EventInfo, 354
FieldInfo, 354, 359, 360
Invoke(), 362
MemberInfo, 354
MethodInfo, 351, 354, 362-364
ParameterInfo, 354, 357
PropertyInfo, 354, 358, 359
runtime invocation, 362-364
System.Runtime.Serialization.Formatters.Binary.BinaryFormatter, 370
RegularExpressions, 228-235
expression syntax, 228-230
Group, 233
Regex, 231-234
Split(), 233
Replace(), 234
StringBuilder, 23, 147, 195
System.Threading, 235-241
Monitor, 240-241
Enter(), 240-241
Exit(), 240-241
TryEnter(), 241
Thread, 236-239
Abort(), 239
Join(), 239
Resume(), 238
Sleep(), 237
Start(), 238
Suspend(), 238
ThreadPool, 241
ThreadStart class, 238
System.Type, 131, 351
access to Info classes, 355
gateway to reflection, 354-356
GetType(), 351
System.Xml, 259-281
interop with DataSet, 259
Schema, 281
Serialization, 281
whitespace, 268
260-263, 272-277
XmlNode hierarchy, 274-276
XmlNodeType, 268-270
XmlSerializer, 263
XmlTextReader, 265-272
XmlTextWriter, 263
XPath, 279-281
XPathNavigator, 279
MoveToFirstChild(), 280
MoveToNext(), 280
Select(), 280
SelectChildren(), 280
XPathDocument, 279
Xsl, 277-279
Load(), 277
Transform(), 277
XslTransform, 277


throw, see exception handling
ToString(), 36, 146
try block, see exception handling
type cast, see conversion
alias for System, 51, 199-200
bool, 14
byte, 35, 49
char, 50
conversion, 37, 49
decimal, 50, 172
double, 50
float, 50
int, 49
long, 49
numeric literals, 49
numeric types, 49-51
predefined, 5
promotion, 50
reference, 28, 36
run-time query, 38
string, 21-23
Equals(), 14
immutable, 23
Split(), 21
unified type system, 35-38
unsigned, 49
value, 28, 36
verbatim string literal, 17
void, 11


unboxing, 37-38
unified type system, see types
unmanaged method call, 370
unmanged resources
see System.IDisposable
unsigned, see types
directive, 2, 4, 8
directive alias, 9
directive vs. qualified name, 5
statement, 190


value types, 28-29, 36
See also enum
See also struct
variable-length parameter list,
see params keyword
see class member function
virtual, see object-oriented
see name
see namespaces
Visual Studio
add new item, 65
build program, 65
Class View window, 65
compiler errors, 65
execute program, 65
opening a project, 63-65
Properties window, 286, 287, 290
renaming file, 65
Solution Explorer, 64
Toolbox window, 288
void, as return type, 11


Web Forms designer, see ASP.NET
Win32 API, 370
See also Attributes, DllImport
Windows, 283-314
Bitmap class, 312
Button, 293-294, 304
CheckBox, 306
ContextMenu, 307
DataGrid, 308-310
FileDialog, 302-303
Labels, 296-297
ListBox, 299-302
Menus, 306-307
PictureBox, 310-312
RadioButton, 305
TextBox, 292, 292-293
event handlers, 288-295
Click, 293
inspecting events, 295-296
OnPaint(), 313
Quit, 295
TextChanged, 292
MessageBox, 294, 298-299
Project, 285-288
Code view, 290
Designer view, 286, 290
inspecting events, 295
opening a project, 285
Properties window, 286-287, 290
Toolbox window, 288
write, see output, System.IO



Click below for Errata related to this title:

Submit Errata

More Information

Unlimited one-month access with your purchase
Free Safari Membership