rent-now

Rent More, Save More! Use code: ECRENTAL

5% off 1 book, 7% off 2 books, 10% off 3+ books

9780735616486

Inside C#, Second Edition

by
  • ISBN13:

    9780735616486

  • ISBN10:

    0735616485

  • Edition: 2nd
  • Format: Paperback
  • Copyright: 2002-05-24
  • Publisher: Microsoft Pr
  • Purchase Benefits
  • Free Shipping Icon Free Shipping On Orders Over $35!
    Your order must be $35 or more to qualify for free economy shipping. Bulk sales, PO's, Marketplace items, eBooks and apparel do not qualify for this offer.
  • eCampus.com Logo Get Rewarded for Ordering Your Textbooks! Enroll Now
List Price: $49.99

Summary

Aimed at those with some previous programming experience, Inside C# shows developers the unique strengths, advantages, and tips for coding with C#. This fast-paced and in-depth tutorial will let you use Microsoft's newest programming language on the emerging .NET platform successfully.The outstanding strength of this text is its in-depth language tutorial on C#, with complete coverage of basic and advanced object-oriented programming techniques. New language features like properties, indexers, and attributes get full coverage, alongside the basics of using classes and inheritance. The book relies on using Visual Studio 6.0 and the command-line .NET tools for running programs. (Visual Studio.NET, the next version of Visual Studio, was unavailable when the book was written.) First to market with an in-depth language tutorial, the focus of Inside C# is on basic and advanced language features. By viewing generated code (using the ILDASM disassembler tool), the author examines how class design features work under the hood. The language tutorial digs into features, beginning with a "Hello, World" program and delving into class design features before moving on to more basic features like expressions, operators, and flow control. This sequence makes the book best suited to the experienced developer, since some excellent in-depth material on the most advanced features of C# is presented before the basics of the language. Throughout, you'll learn the newest features of the language, how to use it, and a sense of its personality.There's also plenty of material on the underlying Microsoft .NET platform, from the basics of the Common Language Runtime (CLR) to assemblies (used to deploy .NET applications), plus getting older COM components to interoperate with the newer .NET standard. For anyone who's programmed before and wants to learn C# quickly, this in-depth guide anchored with plenty of short, effective examples provides what you need. Inside C# shows off the unique strengths of this new and exciting language and provides a solid introduction to the .NET platform. --Richard DraganTopics covered: Introduction to C# and the Microsoft .NET Framework Tutorial for object-oriented programming A "Hello, World" program in C# Command-line .NET tools (including the C# compiler and the ILDASM disassembler) C# types Boxing and unboxing variables In-depth guide to C# class design (including members and methods, constructors, constants and read-only fields, garbage collection, and inheritance) Method overloading Virtual and static methods Properties Arrays Indexers Attributes Interfaces (declaring and implementing interfaces, plus interfaces combined with inheritance) Expressions and operators in C# (including operator precedence) Program flow control Exception handling classes and techniques Operator overloading Delegates and event handlers Multithreaded programming techniques (including thread safety and synchronization) C# reflection and metadata Using unmanaged code and pointers from within C# COM interoperability Assemblies and deployment in C#

Table of Contents

Foreword xix
Introduction xxiii
Part I C# Class Fundamentals
Building C# Applications and Libraries
3(36)
``Hello, World''---The Command-Line Version
4(3)
Using the Command-Line Compiler
4(3)
``Hello, World'' Code Walk-Through
7(8)
One-Stop Programming
7(1)
Namespaces
8(2)
Classes and Members
10(1)
The Main Method
11(1)
The System.Console.WriteLine Method
11(1)
Namespaces and the using Directive
12(1)
Skeleton Code
13(1)
Class Ambiguity
14(1)
``Hello, World''---The Visual Studio .NET Version
15(3)
Building and Running .NET Applications
18(2)
Inside ``Hello, World''
20(4)
Working with Assemblies and Modules
24(13)
Assembly Overview
25(1)
Benefits of Assemblies
26(1)
Building Assemblies
27(5)
Creating Shared Assemblies
32(3)
Working with the Global Assembly Cache
35(2)
Summary
37(2)
The .NET Type System
39(20)
Everything Is an Object
40(3)
The Root of All Types: System.Object
41(2)
Value Types and Reference Types
43(2)
Value Types
43(1)
Reference Types
44(1)
Boxing and Unboxing
45(8)
Converting from Value Types to Reference Types
45(1)
Converting from Reference Types to Value Types
46(2)
More Boxing Examples
48(5)
Types and Aliases
53(1)
Casting Between Types
54(2)
CTS Benefits
56(2)
Language Interoperability
57(1)
Singly Rooted Object Hierarchy
57(1)
Type Safety
58(1)
Summary
58(1)
Classes and Structs
59(40)
Defining Classes
59(1)
Class Members
60(2)
Access Modifiers
62(1)
The Main Method
63(5)
Command-Line Arguments
64(2)
Returning Values from Main
66(1)
Multiple Main Methods
67(1)
Constructors
68(13)
Static Members and Instance Members
71(2)
Constructor Initializers
73(5)
Specifying Run-Time Information in a Constructor Initializer
78(3)
Constants vs. Read-Only Fields
81(6)
Constants
81(2)
Read-Only Fields
83(4)
Inheritance
87(5)
Multiple Interfaces
90(1)
Sealed Classes
91(1)
Defining Structs in C#
92(5)
Struct Usage
92(3)
Guidelines to Using Structs
95(2)
Summary
97(2)
Methods
99(42)
Value and Reference Parameters
100(9)
ref Method Parameters
101(4)
out Method Parameters
105(4)
Value and Reference Parameters (Again)
109(4)
Method Overloading
113(6)
Overloading Constructors
115(3)
Inheritance and Overloading
118(1)
Variable Method Parameters
119(3)
Virtual Methods
122(14)
Method Overriding
123(1)
Polymorphism
124(7)
new and virtual Methods
131(3)
Calling Virtual Methods from Constructors
134(2)
Static Methods
136(4)
Access to Class Members
137(1)
Static Constructors
138(2)
Summary
140(1)
Properties, Arrays, and Indexers
141(30)
Properties as Smart Fields
142(14)
Defining and Using Properties
143(2)
Inside Properties
145(5)
Inheriting Properties
150(5)
Advanced Use of Properties
155(1)
Arrays
156(8)
Declaring Arrays
156(1)
Single-Dimensional Array Example
157(1)
Multidimensional Arrays
158(2)
Querying for Rank
160(2)
Jagged Arrays
162(2)
Treating Objects Like Arrays by Using Indexers
164(6)
Defining Indexers
165(1)
Indexer Example
165(2)
Inside Indexers
167(2)
Design Guidelines
169(1)
Summary
170(1)
Attributes
171(42)
Introducing Attributes
172(1)
Defining Attributes
173(4)
Querying for Attributes
177(7)
Class Attributes
177(3)
Method Attributes
180(2)
Field Attributes
182(2)
Attribute Parameters
184(3)
Positional Parameters and Named Parameters
184(2)
Common Mistakes with Named Parameters
186(1)
Valid Attribute Parameter Types
187(1)
The AttributeUsage Attribute
187(6)
Defining an Attribute Target
188(2)
Single-Use and Multiuse Attributes
190(1)
Specifying Inheritance Attribute Rules
191(2)
Attribute Identifiers
193(2)
Predefined Attributes
195(10)
Conditional Attribute
197(2)
Obsolete Attribute
199(1)
CLSCompliant Attribute
200(1)
DllImport and StructLayout Attributes
201(2)
Assembly Attributes
203(2)
Context Attributes
205(7)
Summary
212(1)
Interfaces
213(36)
Interface Use
214(1)
Declaring Interfaces
215(2)
Implementing Interfaces
217(13)
Querying for Implementation by Using is
219(5)
Querying for Implementation by Using as
224(3)
Interfaces vs. the Alternatives
227(3)
Explicit Interface Member Name Qualification
230(8)
Name Hiding with Interfaces
230(3)
Avoiding Name Ambiguity
233(5)
Interfaces and Inheritance
238(4)
Combining Interfaces
242(3)
Summary
245(4)
Part II Writing Code
Expressions and Operators
249(36)
Operators Defined
249(1)
Operator Precedence
250(3)
How C# Determines Precedence
251(1)
Left and Right Associativity
252(1)
Practical Usage
253(1)
C# Operators
253(16)
Primary Expression Operators
253(6)
Mathematical Operators
259(10)
Numeric Conversions
269(3)
checked and unchecked Context
271(1)
Bitwise Operators
272(12)
Relational Operators
276(2)
Simple Assignment Operators
278(4)
The Conditional Operator
282(2)
Summary
284(1)
Program Flow Control
285(44)
Selection Statements
285(16)
The if Statement
285(7)
The switch Statement
292(9)
Iteration Statements
301(12)
The while Statement
301(1)
The do/while Statement
302(3)
The for Statement
305(5)
The foreach Statement
310(3)
Branching with Jump Statements
313(14)
The break Statement
313(4)
The continue Statement
317(2)
The Infamous goto Statement
319(7)
The return Statement
326(1)
Summary
327(2)
String Handling and Regular Expressions
329(44)
Strings
330(23)
String Formatting
333(1)
Format Specifiers
334(4)
Objects and ToString
338(1)
Numeric String Parsing
339(2)
Strings and DateTime
341(4)
Encoding Strings
345(1)
The StringBuilder Class
346(1)
Splitting Strings
347(1)
Extending Strings
348(2)
String Interning
350(3)
Regular Expressions
353(19)
Match and MatchCollection
358(3)
Groups and Captures
361(2)
String-Modifying Expressions
363(4)
Regular Expression Options
367(1)
Compiling Regular Expressions
368(4)
Summary
372(1)
File I/O with Streams
373(38)
Stream Classes
373(16)
FileStream
375(4)
StreamReader and StreamWriter
379(2)
Memory and Buffered Streams
381(3)
String Readers and Writers
384(3)
Binary Readers and Writers
387(2)
File System Classes
389(6)
Directory and DirectoryInfo
389(3)
File and FileInfo
392(2)
Parsing Paths
394(1)
Nonconsole Use of Streams
395(4)
Windows OpenFileDialog
395(2)
Reading Web Pages
397(2)
Serialization
399(10)
Serializing with BinaryFormatter
399(4)
Serializing with SoapFormatter
403(1)
Serializing with XmlSerializer
404(2)
Implementing ISerializable
406(3)
Summary
409(2)
Error Handling with Exceptions
411(38)
Overview of Exception Handling
411(2)
Basic Exception-Handling Syntax
413(11)
Throwing an Exception
413(1)
Catching an Exception
414(4)
Rethrowing an Exception
418(2)
Cleaning Up with finally
420(4)
Retrying Code
424(2)
Comparing Error-Handling Techniques
426(6)
Benefits of Exception Handling Over Return Codes
427(2)
Handling Errors in the Correct Context
429(1)
Improving Code Readability
430(2)
Throwing Exceptions from Constructors
432(1)
Using the System.Exception Class
432(9)
Constructing an Exception Object
432(4)
Using the StackTrace Property
436(1)
Catching Multiple Exception Types
437(1)
Deriving Your Own Exception Classes
438(3)
Designing Your Code with Exception Handling
441(7)
Design Issues with the try Block
441(4)
Design Issues with the catch Block
445(3)
Summary
448(1)
Operator Overloading and User-Defined Conversions
449(32)
Operator Overloading
450(14)
Operator Overloading Syntax
450(1)
Operator Overloading Rules and Restrictions
451(2)
Operator Overloading Examples
453(3)
RGB Color Incrementing Example
456(6)
Operator Overloading Design Guidelines
462(2)
User-Defined Conversions
464(15)
User-Defined Conversion Syntax
465(1)
User-Defined Conversion Rules and Restrictions
465(1)
User-Defined Conversion Examples
465(14)
Summary
479(2)
Delegates and Event Handlers
481(30)
Using Delegates as Callback Methods
481(4)
Inside Delegates
485(4)
Defining Delegates as Static Members
489(3)
Creating Delegates Only When Needed
492(3)
Multicast Delegates
495(9)
Multicast Delegate Justification
501(3)
Defining Events with Multicast Delegates
504(5)
Summary
509(2)
Documentation with XML
511(32)
Getting Started
511(4)
Adding Elements
514(1)
Acceptable Code Constructs
514(1)
Compiler-Generated Element IDs
515(8)
Fields, Properties, Events, and Indexers
516(2)
Methods
518(5)
Well-Formed XML
523(2)
Comment Web Pages
525(1)
Element Tags and Attributes
526(8)
The <exception> Tag and cref Attribute
528(1)
The <c>, <code>, and <example> Tags
529(1)
The <include> Tag
530(3)
The <list> Tag
533(1)
Custom Formatting
534(3)
XML and Data
537(2)
Summary
539(4)
Part III Advanced C#
Numerical Processing and the Math Class
543(20)
Numeric Support in C# and .NET
543(9)
Is the Decimal Type a Primitive?
545(2)
Numeric Suffixes
547(1)
A Numeric Type by Any Other Name
547(2)
More on Numeric Literals
549(3)
Integral Ranges and Overflow Rules
552(5)
The Decimal Type
557(1)
The System.Math Class
558(1)
System.Math Constants
558(2)
Working with a Number's Sign
558(1)
Minimum and Maximum Values
559(1)
Methods for Rounding and Truncating
560(1)
Summary
560(3)
Collections and Object Enumeration
563(34)
Implementing the Enumeration Interface
563(8)
Using an Enumerator Object
568(1)
Using the foreach Statement with Collections
569(2)
Two Interfaces for the Price of One
571(1)
Constructing Enumerator Objects
572(1)
Creating Versioned Enumerators
573(4)
Combining IEnumerable and IEnumerator
577(2)
Protecting Data While Allowing Enumeration
579(3)
Value Types
582(14)
Performance Issues
583(9)
Modified Collected Value Types
592(4)
Summary
596(1)
Multithreading and Asynchronous Programming
597(38)
Getting Started with Threads
597(2)
Basic Thread-Handling Chores
599(11)
Creating Threads and Thread Objects
599(1)
Managing Thread Lifetimes
599(2)
Destroying Threads
601(4)
Scheduling Threads
605(5)
Communicating Data to a Thread
610(2)
Thread Safety and Synchronization
612(12)
Protecting Code by Using the Monitor Class
613(7)
Using Monitor Locks with the C# lock Statement
620(2)
Synchronizing Code by Using the Mutex Class
622(2)
Using Delegates to Call Asynchronous Methods
624(6)
Thread Safety and the .NET Classes
630(1)
Threading Guidelines
630(2)
When to Use Threads
631(1)
When Not to Use Threads
632(1)
Summary
632(3)
Querying Metadata with Reflection
635(26)
The Reflection API Hierarchy
635(1)
The Type Class
636(1)
Retrieving a Type Reference
636(6)
Retrieving the Type of an Instance
637(1)
Retrieving the Type from a Name
637(2)
Interrogating Types
639(3)
Working with Assemblies and Modules
642(8)
Iterating Through the Types of an Assembly
642(6)
Listing an Assembly's Modules
648(2)
Late Binding with Reflection
650(3)
Implementing an Abstract Factory with Reflection
653(3)
Dynamic Code Generation
656(4)
Summary
660(1)
Pinning and Memory Management
661(42)
Garbage Collection
662(1)
Overriding Finalize
663(7)
Overriding Finalize in Derived Classes
667(3)
Forcing Garbage Collection
670(2)
The Dispose Pattern
672(4)
Other GC Features
675(1)
The IDisposable Interface
676(7)
Derived Disposable Classes
678(2)
Protecting Against Double Disposal
680(2)
Language Support for Dispose
682(1)
Garbage Collector Generations
683(2)
Weak References
685(2)
Unsafe Code
687(5)
Using Pointers in C#
688(4)
Pinning
692(10)
Pinning Array Elements
694(5)
The Dereference Member Operator
699(1)
Using stackalloc
700(2)
Summary
702(1)
Using COM from C# Applications
703(46)
Where COM Fits in Today's .NET World
704(1)
Using COM Components from C#
705(10)
Creating an ATL Component
705(2)
Consuming a COM Component from a .NET Application
707(2)
Binding to and Using the COM Component
709(2)
Dynamic Type Discovery with COM Components
711(2)
Late Binding to COM Objects
713(2)
Event Handling
715(12)
How COM Connection Points Work
715(2)
Creating an ATL COM Component That Sources Events
717(2)
Event Handling Using Delegates
719(3)
Sinking Unmanaged COM Events in a .NET Application
722(5)
Using COM Collections
727(9)
Creating a COM Collection Component Using ATL
727(5)
Consuming COM Collections in a .NET Application
732(2)
Enumerating Elements in a .NET Collection
734(2)
Reusing COM Components in Managed Code
736(9)
Containment
736(1)
Aggregation
737(1)
Reuse Through Mixed-Mode Inheritance
738(4)
Reuse Through Mixed-Mode Containment
742(1)
A .NET View on COM Threading Models and Apartments
743(2)
Mapping Method Keywords to IDL Attributes
745(1)
Summary
746(3)
Using .NET Components in Unmanaged Code
749(34)
Creating and Using .NET Components via COM
749(14)
Generating a Typelib from the Assembly and Registering the Assembly
751(1)
Consuming the Component from a Visual Basic 6 Client
752(1)
Shedding More Light on the COM Interop Wizardry
753(3)
Snooping on the Generated Typelib
756(7)
Using Attributes to Tweak the Generated Typelib Metadata
763(5)
Altering the Interface Type
763(2)
Altering the GUID and the ProgID
765(1)
Hiding Public Types from Exposure to COM
766(1)
Altering the Marshaling Behavior for Types
767(1)
Exception Handling: .NET vs. COM
768(3)
Handling Events from .NET Components in Unmanaged Event Sinks
771(5)
Creating a .NET Component that Sources Events
772(3)
Handling Events in a Visual Basic Client Application
775(1)
Thread Affinity in .NET Components
776(6)
Thread-Neutral Behavior When Accessed by Unmanaged COM-Aware Clients
777(5)
Summary
782(1)
Security
783(56)
.NET Security
783(3)
Threats to Security
784(2)
Verifiable Type Safety
786(5)
Code Signing
791(12)
Private Assemblies
792(2)
Strong-Named Assemblies
794(6)
The Global Assembly Cache
800(2)
Delay-Signed Assemblies
802(1)
Cryptographic Services
803(4)
Code Access Security
807(24)
Evidence
808(1)
Security Policy
809(5)
Configuring Security
814(8)
CASpol
822(3)
Imperative and Declarative CAS
825(2)
Identity Permissions
827(2)
Assembly Permission Requests
829(2)
Role-Based Security
831(4)
PrincipalPermission Requests
833(1)
Impersonation
834(1)
Isolated Storage
835(3)
Summary
838(1)
A MSIL Instruction Table 839(16)
Index 855

Supplemental Materials

What is included with this book?

The New copy of this book will include any supplemental materials advertised. Please check the title of the book to determine if it should include any access cards, study guides, lab manuals, CDs, etc.

The Used, Rental and eBook copies of this book are not guaranteed to include any supplemental materials. Typically, only the book itself is included. This is true even if the title states it includes any access cards, study guides, lab manuals, CDs, etc.

Rewards Program