Добавил:
Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
CSharp - Your Visual Blueprint For Building .NET Applications (2002) [eng].pdf
Скачиваний:
39
Добавлен:
16.08.2013
Размер:
9.71 Mб
Скачать

TABLE OF CONTENTS

HOW TO USE THIS BOOK . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .xiv

1) GETTING STARTED WITH C#

 

Introduction to C# ..............................................................................................................

2

Start Visual Studio .NET ......................................................................................................

4

Open a New C# Project ......................................................................................................

6

View .NET Framework Online Resources ..........................................................................

8

Open a C# Web Project ....................................................................................................

10

Set JScript.NET as the Default Script Language ..............................................................

12

2) EXPLORING THE C# INTERFACE

 

Explore the Class View Window ......................................................................................

14

View the Contents Window ..............................................................................................

16

Get Help Using the Index Window ..................................................................................

18

Search for Help ................................................................................................................

20

Add Components from the Toolbox ................................................................................

22

Add a Task to the Task List ................................................................................................

24

Change Form Properties in the Properties Window ......................................................

26

Add a Custom Toolbar ......................................................................................................

28

Delete a Toolbar ................................................................................................................

30

Change the Visual Studio Environment ..........................................................................

32

Manage Open Windows ..................................................................................................

34

3) WORKING WITH VISUAL C# BASICS

 

Open a Project ..................................................................................................................

36

View The Main Method ....................................................................................................

38

Combine Program Types ..................................................................................................

40

Add Reference Types ........................................................................................................

42

Add Operators ..................................................................................................................

44

Insert Attributes ................................................................................................................

46

Enter Classes ......................................................................................................................

50

Add Comments to Code ..................................................................................................

54

Write Your First Program ..................................................................................................

56

Enter XML Documentation ..............................................................................................

58

Access Documentation ......................................................................................................

60

Log a Bug Report ................................................................................................................

62

viii

C#:

Your visual blueprint for building .NET applications

4) PROGRAMMING C# BUILDING BLOCKS

 

View Information about C# Building Blocks ..................................................................

64

Program Classes ................................................................................................................

66

Add a Class ........................................................................................................................

68

Employ Class Inheritance ..................................................................................................

72

Program Instance Constructors ........................................................................................

74

Insert Destructors ..............................................................................................................

78

Program Structs ..................................................................................................................

80

Display Heap and Stack Information ..............................................................................

84

5) WORKING WITH TYPES AND INTERFACES

 

Find Type Information ......................................................................................................

86

Program Constant Expressions ........................................................................................

88

Specify Value Types ............................................................................................................

90

Program Numeric Types ....................................................................................................

92

Program the Boolean Type ................................................................................................

96

Declare Reference Types ..................................................................................................

98

Enter Reference Type Declarations ................................................................................

100

Convert Value Types to Reference Types ......................................................................

104

Program Pointer Types ....................................................................................................

106

Insert The Void Type ........................................................................................................

108

Add Interface Properties ................................................................................................

110

Add an Interface Index ....................................................................................................

112

6) PROGRAMMING METHODS AND EVENTS

 

View Information about Methods ..................................................................................

116

Add a Method ..................................................................................................................

118

Add Static Methods ........................................................................................................

122

Include Non-Static Methods ..........................................................................................

126

Enter Delegates ................................................................................................................

130

Program Events ................................................................................................................

132

Add an Event-Handling Method ....................................................................................

134

ix

TABLE OF CONTENTS

7) USING ARRAYS

 

View Information About Arrays ......................................................................................

136

Enter Single-Dimensional Arrays ....................................................................................

138

Add Multidimensional Arrays ........................................................................................

140

Program Array-of-Arrays ................................................................................................

142

Iterate Through Array Elements ......................................................................................

144

Sort Arrays ........................................................................................................................

146

Search Arrays ....................................................................................................................

148

Implement a Collections Class ......................................................................................

150

Program Structs ................................................................................................................

152

Add an Indexer ................................................................................................................

154

Include Enumerations ......................................................................................................

156

8) WORKING WITH STRINGS

 

Create String Literals and Variables ..............................................................................

158

Assign Values to Strings ..................................................................................................

160

Concatenate Strings ........................................................................................................

162

Compare Strings ..............................................................................................................

164

Search for Substrings ......................................................................................................

166

Replace Characters ..........................................................................................................

168

Extract Substrings ............................................................................................................

170

Change the Character Case ............................................................................................

172

Trim Spaces ......................................................................................................................

174

Remove Characters ..........................................................................................................

176

Split a String ....................................................................................................................

178

Join Strings ........................................................................................................................

180

Pad Strings ........................................................................................................................

182

x

C#:

Your visual blueprint for building .NET applications

9) ACCESSING PROPERTIES

 

View Information About Properties ..............................................................................

184

Compare Properties and Indexers ................................................................................

186

Program Property Accessors ..........................................................................................

188

Declare Abstract Properties ............................................................................................

192

Include Properties on Interfaces ....................................................................................

194

10) BUILDING FORMS

 

View Information About Windows Forms ....................................................................

196

Add a Windows Form in the Windows Form Designer ..............................................

198

Set the Form Type ............................................................................................................

200

Choose the Startup Windows Form ..............................................................................

202

Create a Modal Form ......................................................................................................

204

Layout a Form ..................................................................................................................

206

Set a Form Location ........................................................................................................

210

Change Form Properties ................................................................................................

212

Create a Transparent Form ............................................................................................

214

11) PROGRAMMING WEB APPLICATIONS

 

Introduction to Web Forms and Controls ....................................................................

216

Create an ASP.NET Web Site ..........................................................................................

218

Create a Web Form ..........................................................................................................

220

Add Server Controls to a Web Form ............................................................................

222

Respond to an Event in Server-Side Controls ..............................................................

224

Read and Change Properties from Objects on a Web Form ......................................

226

Using Server-Side Components on Web Forms ..........................................................

228

xi

TABLE OF CONTENTS

12) ACCESSING DATA WITH C# AND ADO.NET

 

Introducing Data Access with ADO.NET ......................................................................

230

Display Data with the DataGrid Control ......................................................................

232

Configure the DataGrid Control ....................................................................................

234

Insert Data into a SQL Database ....................................................................................

236

Update Data from a SQL Database ..............................................................................

238

Delete Data from a SQL Database ................................................................................

240

Execute a Stored Procedure in a SQL Database ..........................................................

242

13) USING THE XML FRAMEWORK CLASS

 

Read XML from a File ......................................................................................................

244

Save XML to a File ............................................................................................................

246

Query XML with XPath ....................................................................................................

248

Apply XSL to XML ............................................................................................................

250

14)CREATING AND DEPLOYING DISTRIBUTED APPLICATIONS

Introduction to Distributed Applications ......................................................................

252

Create an Application with Private Assemblies ............................................................

254

Create an Application with Shared Assemblies ............................................................

260

Version a Shared Assembly ............................................................................................

266

Configure a Client for a Versioned Assembly ..............................................................

268

Create a Web Service ......................................................................................................

270

Using a Web Service ........................................................................................................

272

xii

C#:

Your visual blueprint for building .NET applications

15) WORKING WITH ERRORS

 

Introduction to Exception Handling ..............................................................................

274

Throwing an Exception ....................................................................................................

276

Executing Code Using the Try/Catch Blocks ................................................................

278

Handling Exceptions with the Catch Block ..................................................................

280

Using the Finally Block ....................................................................................................

282

Write Errors to the Application Log ..............................................................................

284

APPENDIX A) C# QUICK REFERENCE

 

Basic Examples ................................................................................................................

286

APPENDIX B) ABOUT THE CD-ROM

 

What’s on the CD-ROM ..................................................................................................

290

Using the E-Version of This Book ....................................................................................

292

Hungry Minds, Inc. End-User License Agreement ........................................................

294

INDEX . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .296

xiii

Соседние файлы в предмете Программирование на C++