C Sharp Bible - [Wiley], C#
[ Pobierz całość w formacie PDF ]
C# Bible
Jeff Ferguson, Brian Patterson, Jason Beres,
Pierre Boutquin, and Meeta Gupta
Published by
Wiley Publishing, Inc.
10475 Crosspoint Boulevard
Indianapolis,_IN 46256
www.wiley.com
Copyright © 2002 by Wiley Publishing, Inc., Indianapolis, Indiana
Published simultaneously in Canada
Library of Congress Control Number: 2001092884
ISBN: 0-7645-4834-4
Manufactured in the United States of America
10 9 8 7 6 5 4 3 2 1
1B/ST/QX/QS/IN
No part of this publication may be reproduced, stored in a retrieval system or transmitted in
any form or by any means, electronic, mechanical, photocopying, recording, scanning or
otherwise, except as permitted under Sections 107 or 108 of the 1976 United States Copyright
Act, without either the prior written permission of the Publisher, or authorization through
payment of the appropriate per-copy fee to the Copyright Clearance Center, 222 Rosewood
Drive, Danvers, MA 01923, (978) 750-8400, fax (978) 750-4744. Requests to the Publisher
for permission should be addressed to the Legal Department, Wiley Publishing, Inc., 10475
Crosspoint Blvd., Indianapolis, IN 46256, (317) 572-3447, fax (317) 572-4447, E-Mail:
permcoordinator@wiley.com
.
LIMIT OF LIABILITY/DISCLAIMER OF WARRANTY: WHILE THE PUBLISHER AND
AUTHOR HAVE USED THEIR BEST EFFORTS IN PREPARING THIS BOOK, THEY
MAKE NO REPRESENTATIONS OR WARRANTIES WITH RESPECT TO THE
ACCURACY OR COMPLETENESS OF THE CONTENTS OF THIS BOOK AND
SPECIFICALLY DISCLAIM ANY IMPLIED WARRANTIES OF MERCHANTABILITY
OR FITNESS FOR A PARTICULAR PURPOSE. NO WARRANTY MAY BE CREATED
OR EXTENDED BY SALES REPRESENTATIVES OR WRITTEN SALES MATERIALS.
THE ADVICE AND STRATEGIES CONTAINED HEREIN MAY NOT BE SUITABLE
FOR YOUR SITUATION. YOU SHOULD CONSULT WITH A PROFESSIONAL WHERE
APPROPRIATE. NEITHER THE PUBLISHER NOR AUTHOR SHALL BE LIABLE FOR
ANY LOSS OF PROFIT OR ANY OTHER COMMERCIAL DAMAGES, INCLUDING
BUT NOT LIMITED TO SPECIAL, INCIDENTAL, CONSEQUENTIAL, OR OTHER
DAMAGES.
For general information on our other products and services or to obtain technical support,
please contact our Customer Care Department within the U.S. at 800-762-2974, outside the
U.S. at (317) 572-3993 or fax (317) 572-4002.
Wiley also publishes its books in a variety of electronic formats. Some content that appears in
print may not be available in electronic books.
Trademarks:
Wiley, the Wiley Publishing logo and related trade dress are trademarks or
registered trademarks of Wiley Publishing, Inc., in the United States and other countries, and
may not be used without written permission. All other trademarks are the property of their
respective owners. Wiley Publishing, Inc., is not associated with any product or vendor
mentioned in this book.
About the Authors
Jeff Ferguson
is a senior consultant with Magenic Technologies, a software consulting
company dedicated to solving business problems exclusively using Microsoft tools and
technologies. He has been a professional software developer since 1989 and has developed
software using C, C++, and C# for Unix, DOS, and Windows systems. Send e-mail to Jeff at
JeffF@magenic.com
(remember to include all three "F"s in the name portion of the address).
Brian Patterson
currently works for Affina, Inc., as a Technical Team Leader, where he is
generally working with C++ on HP-UX or Windows development with any number of the
Visual Studio languages. Brian has been writing for various Visual Basic publications since
1994 and has co-written several .NET-related books, including
Migrating to Visual Basic
.NET
and
.NET Enterprise Development with VB.NET
. You can generally find him posting in
the MSDN newsgroups or you can reach him by e-mail at
BrianDPatterson@msn.com
.
Jason Beres
has been a software developer for 10 years. He is currently a consultant in south
Florida and works exclusively with Microsoft technologies. Jason holds the MCT, MCSD,
and MCDBA certifications from Microsoft. When he is not teaching, consulting, or writing,
he is formatting his hard drive, installing the latest beta products from Microsoft, and keeping
up with the latest episodes of "Star Trek."
Pierre Boutquin
is a senior software architect in the treasury of a major Canadian bank,
where he helps develop leading-edge market risk management software. He has more than a
decade of experience implementing PC-based computer systems, with in-depth knowledge of
distributed systems design, data warehousing, Visual Basic, Visual C++, and SQL. He has co-
written many programming books and has contributed material on VB, COM+, XML, and
SQL to other books. Koshka and Sasha, his two adorable Burmese cats, own most of Pierre's
spare time. While petting them, he often thinks how nice it would be to find more time and
get back into chess or keep up with news from Belgium, his native country. You can reach
him at
boutquin@hotmail.com
.
Meeta Gupta
has a master's degree in computer engineering. Networking is her first love.
She is presently working at NIIT Ltd., where she designs, develops, and authors books on a
varied range of subjects. She has co-written books on TCP/IP, A+ Certification, ASP.NET,
and PHP. She also has an extensive experience in designing and developing ILTs. Besides
writing, Meeta has conducted courses on C++, Sybase, Windows NT, Unix, and HTML for a
diverse audience, from students to corporate clients.
NIIT
is a global IT solutions company that creates customized multimedia training products
and has more than 2,000 training centers worldwide. NIIT has more than 4,000 employees in
37 countries and has strategic partnerships with a number of major corporations, including
Microsoft and AT&T.
About the Series Editor
Michael Lane Thomas
is an active development community and computer industry analyst
who presently spends a great deal of time spreading the gospel of Microsoft .NET in his
current role as a .NET technology evangelist for Microsoft. In working with over a half-dozen
publishing companies, Michael has written numerous technical articles and written or
contributed to almost 20 books on numerous technical topics, including Visual Basic, Visual
C++, and .NET technologies. He is a prolific supporter of the Microsoft certification
programs, having earned his MCSD, MCSE+I, MCT, MCP+SB, and MCDBA.
In addition to technical writing, Michael can also be heard over the airwaves from time to
time, including two weekly radio programs on Entercom (
)
stations, including most often in Kansas City on News Radio 980KMBZ
(
). He can also occasionally be caught on the Internet doing an MSDN
Webcast (
)
discussing .NET, the next generation of
Web application technologies.
Michael started his journey through the technical ranks back in college at the University of
Kansas, where he earned his stripes and a couple of degrees. After a brief stint as a technical
and business consultant to Tokyo-based Global Online Japan, he returned to the States to
climb the corporate ladder. He has held assorted roles, including those of IT manager, field
engineer, trainer, independent consultant, and even a brief stint as Interim CTO of a
successful dot-com, although he believes his current role as .NET evangelist for Microsoft is
the best of the lot. He can be reached via e-mail at
mlthomas@microsoft.com
.
Credits
Senior Acquisitions Editor
Sharon Cox
Project Editor
Eric Newman
Development Editor
Sydney Jones
Copy Editor
Luann Rouff
Technical Editor
Sundar Rajan
Editorial Manager
Mary Beth Wakefield
Vice President & Executive Group Publisher
Richard Swadley
Vice President and Publisher
Joseph B. Wikert
Project Coordinator
Ryan T. Steffen
Graphics and Production Specialists
Beth Brooks, Melanie DesJardins,
Joyce Haughey, Barry Offringa,
Laurie Petrone, Betty Schulte,
Jeremey Unger
Quality Control Technicians
Laura Albert, Susan Moritz
Proofreading and Indexing
TECHBOOKS Production Services
For my family and my friends.
Jeff Ferguson
This book is dedicated to my uncle, Brian Weston, who didn't seem to
mind when I came to visit and spent all day with his TRS-80 Model II.
Brian Patterson
To Nitin, who was the driving force.
Meeta Gupta
Preface
Microsoft's .NET Framework represents the most significant change in software development
methodology for a Microsoft operating system since the introduction of Windows. It is built
using an architecture that allows software languages to work together, sharing resources and
code, to provide developers with the advanced tools necessary to build the next generation of
desktop and Internet-enabled applications. Microsoft's Visual Studio .NET product includes
new versions of their Visual Basic and C++ compiler products that target .NET development,
as well as a brand new language called C# (pronounced "C-sharp").
C# Bible
will show you how to write code using this brand new language. Language
constructs such as statements, variables, control loops, and classes are all covered. In addition,
the book will show you how to apply C# to programming tasks that developers often face in
the real world. The final portions of the book will show you how to use C# to develop Web
sites, access databases, work with legacy COM and COM+ objects, develop Windows
desktop applications, work with various .NET Framework concepts, and more.
The primary focus of this book is .NET development using C# as the implementation
language and the .NET Framework's C# command-line compiler as the primary development
tool. C# development using the Visual Studio .NET tool is not covered in this book, although
the task of using Visual Studio .NET to develop C# applications can be easily mastered once
the fundamentals of .NET development using C# are well understood.
Who Should Read This Book
This book was written with both the novice and experienced developer in mind. If you know
nothing at all about the basics of software development, this book will get you started with the
fundamentals, teaching you how variables, control loops, and classes work. The book will
also speak to developers of any skill level, showing you the .NET tools available for C#
development and providing you with tips to make your own C# applications work seamlessly
within the .NET Framework development guidelines.
If you already have delved into the world of creating .NET applications, you will find this
book a useful resource, because it covers almost every aspect of .NET development in depth.
The first three parts of the book serve as an illustrative reference to using features of the C#
language. By contrast, the final two portions of the book are dedicated to showcasing C# as an
application development platform, illustrating the role of C# in desktop-, Web-, database-,
and component-based applications.
This book assumes that you are seeing C# for the very first time and aims to provide an
understanding of the language without requiring any previous language expertise. The book
does assume, however, that you are familiar with the application environments used in
conjunction with your C# applications. The final portions of this book cover the use of C#
with desktop, Web, database and component applications, but does not explain those
platforms in detail. Rather, the book assumes that you have a working knowledge of those
application platforms.
[ Pobierz całość w formacie PDF ]
zanotowane.pl doc.pisz.pl pdf.pisz.pl lemansa.htw.pl
C# Bible
Jeff Ferguson, Brian Patterson, Jason Beres,
Pierre Boutquin, and Meeta Gupta
Published by
Wiley Publishing, Inc.
10475 Crosspoint Boulevard
Indianapolis,_IN 46256
www.wiley.com
Copyright © 2002 by Wiley Publishing, Inc., Indianapolis, Indiana
Published simultaneously in Canada
Library of Congress Control Number: 2001092884
ISBN: 0-7645-4834-4
Manufactured in the United States of America
10 9 8 7 6 5 4 3 2 1
1B/ST/QX/QS/IN
No part of this publication may be reproduced, stored in a retrieval system or transmitted in
any form or by any means, electronic, mechanical, photocopying, recording, scanning or
otherwise, except as permitted under Sections 107 or 108 of the 1976 United States Copyright
Act, without either the prior written permission of the Publisher, or authorization through
payment of the appropriate per-copy fee to the Copyright Clearance Center, 222 Rosewood
Drive, Danvers, MA 01923, (978) 750-8400, fax (978) 750-4744. Requests to the Publisher
for permission should be addressed to the Legal Department, Wiley Publishing, Inc., 10475
Crosspoint Blvd., Indianapolis, IN 46256, (317) 572-3447, fax (317) 572-4447, E-Mail:
permcoordinator@wiley.com
.
LIMIT OF LIABILITY/DISCLAIMER OF WARRANTY: WHILE THE PUBLISHER AND
AUTHOR HAVE USED THEIR BEST EFFORTS IN PREPARING THIS BOOK, THEY
MAKE NO REPRESENTATIONS OR WARRANTIES WITH RESPECT TO THE
ACCURACY OR COMPLETENESS OF THE CONTENTS OF THIS BOOK AND
SPECIFICALLY DISCLAIM ANY IMPLIED WARRANTIES OF MERCHANTABILITY
OR FITNESS FOR A PARTICULAR PURPOSE. NO WARRANTY MAY BE CREATED
OR EXTENDED BY SALES REPRESENTATIVES OR WRITTEN SALES MATERIALS.
THE ADVICE AND STRATEGIES CONTAINED HEREIN MAY NOT BE SUITABLE
FOR YOUR SITUATION. YOU SHOULD CONSULT WITH A PROFESSIONAL WHERE
APPROPRIATE. NEITHER THE PUBLISHER NOR AUTHOR SHALL BE LIABLE FOR
ANY LOSS OF PROFIT OR ANY OTHER COMMERCIAL DAMAGES, INCLUDING
BUT NOT LIMITED TO SPECIAL, INCIDENTAL, CONSEQUENTIAL, OR OTHER
DAMAGES.
For general information on our other products and services or to obtain technical support,
please contact our Customer Care Department within the U.S. at 800-762-2974, outside the
U.S. at (317) 572-3993 or fax (317) 572-4002.
Wiley also publishes its books in a variety of electronic formats. Some content that appears in
print may not be available in electronic books.
Trademarks:
Wiley, the Wiley Publishing logo and related trade dress are trademarks or
registered trademarks of Wiley Publishing, Inc., in the United States and other countries, and
may not be used without written permission. All other trademarks are the property of their
respective owners. Wiley Publishing, Inc., is not associated with any product or vendor
mentioned in this book.
About the Authors
Jeff Ferguson
is a senior consultant with Magenic Technologies, a software consulting
company dedicated to solving business problems exclusively using Microsoft tools and
technologies. He has been a professional software developer since 1989 and has developed
software using C, C++, and C# for Unix, DOS, and Windows systems. Send e-mail to Jeff at
JeffF@magenic.com
(remember to include all three "F"s in the name portion of the address).
Brian Patterson
currently works for Affina, Inc., as a Technical Team Leader, where he is
generally working with C++ on HP-UX or Windows development with any number of the
Visual Studio languages. Brian has been writing for various Visual Basic publications since
1994 and has co-written several .NET-related books, including
Migrating to Visual Basic
.NET
and
.NET Enterprise Development with VB.NET
. You can generally find him posting in
the MSDN newsgroups or you can reach him by e-mail at
BrianDPatterson@msn.com
.
Jason Beres
has been a software developer for 10 years. He is currently a consultant in south
Florida and works exclusively with Microsoft technologies. Jason holds the MCT, MCSD,
and MCDBA certifications from Microsoft. When he is not teaching, consulting, or writing,
he is formatting his hard drive, installing the latest beta products from Microsoft, and keeping
up with the latest episodes of "Star Trek."
Pierre Boutquin
is a senior software architect in the treasury of a major Canadian bank,
where he helps develop leading-edge market risk management software. He has more than a
decade of experience implementing PC-based computer systems, with in-depth knowledge of
distributed systems design, data warehousing, Visual Basic, Visual C++, and SQL. He has co-
written many programming books and has contributed material on VB, COM+, XML, and
SQL to other books. Koshka and Sasha, his two adorable Burmese cats, own most of Pierre's
spare time. While petting them, he often thinks how nice it would be to find more time and
get back into chess or keep up with news from Belgium, his native country. You can reach
him at
boutquin@hotmail.com
.
Meeta Gupta
has a master's degree in computer engineering. Networking is her first love.
She is presently working at NIIT Ltd., where she designs, develops, and authors books on a
varied range of subjects. She has co-written books on TCP/IP, A+ Certification, ASP.NET,
and PHP. She also has an extensive experience in designing and developing ILTs. Besides
writing, Meeta has conducted courses on C++, Sybase, Windows NT, Unix, and HTML for a
diverse audience, from students to corporate clients.
NIIT
is a global IT solutions company that creates customized multimedia training products
and has more than 2,000 training centers worldwide. NIIT has more than 4,000 employees in
37 countries and has strategic partnerships with a number of major corporations, including
Microsoft and AT&T.
About the Series Editor
Michael Lane Thomas
is an active development community and computer industry analyst
who presently spends a great deal of time spreading the gospel of Microsoft .NET in his
current role as a .NET technology evangelist for Microsoft. In working with over a half-dozen
publishing companies, Michael has written numerous technical articles and written or
contributed to almost 20 books on numerous technical topics, including Visual Basic, Visual
C++, and .NET technologies. He is a prolific supporter of the Microsoft certification
programs, having earned his MCSD, MCSE+I, MCT, MCP+SB, and MCDBA.
In addition to technical writing, Michael can also be heard over the airwaves from time to
time, including two weekly radio programs on Entercom (
)
stations, including most often in Kansas City on News Radio 980KMBZ
(
). He can also occasionally be caught on the Internet doing an MSDN
Webcast (
)
discussing .NET, the next generation of
Web application technologies.
Michael started his journey through the technical ranks back in college at the University of
Kansas, where he earned his stripes and a couple of degrees. After a brief stint as a technical
and business consultant to Tokyo-based Global Online Japan, he returned to the States to
climb the corporate ladder. He has held assorted roles, including those of IT manager, field
engineer, trainer, independent consultant, and even a brief stint as Interim CTO of a
successful dot-com, although he believes his current role as .NET evangelist for Microsoft is
the best of the lot. He can be reached via e-mail at
mlthomas@microsoft.com
.
Credits
Senior Acquisitions Editor
Sharon Cox
Project Editor
Eric Newman
Development Editor
Sydney Jones
Copy Editor
Luann Rouff
Technical Editor
Sundar Rajan
Editorial Manager
Mary Beth Wakefield
Vice President & Executive Group Publisher
Richard Swadley
Vice President and Publisher
Joseph B. Wikert
Project Coordinator
Ryan T. Steffen
Graphics and Production Specialists
Beth Brooks, Melanie DesJardins,
Joyce Haughey, Barry Offringa,
Laurie Petrone, Betty Schulte,
Jeremey Unger
Quality Control Technicians
Laura Albert, Susan Moritz
Proofreading and Indexing
TECHBOOKS Production Services
For my family and my friends.
Jeff Ferguson
This book is dedicated to my uncle, Brian Weston, who didn't seem to
mind when I came to visit and spent all day with his TRS-80 Model II.
Brian Patterson
To Nitin, who was the driving force.
Meeta Gupta
Preface
Microsoft's .NET Framework represents the most significant change in software development
methodology for a Microsoft operating system since the introduction of Windows. It is built
using an architecture that allows software languages to work together, sharing resources and
code, to provide developers with the advanced tools necessary to build the next generation of
desktop and Internet-enabled applications. Microsoft's Visual Studio .NET product includes
new versions of their Visual Basic and C++ compiler products that target .NET development,
as well as a brand new language called C# (pronounced "C-sharp").
C# Bible
will show you how to write code using this brand new language. Language
constructs such as statements, variables, control loops, and classes are all covered. In addition,
the book will show you how to apply C# to programming tasks that developers often face in
the real world. The final portions of the book will show you how to use C# to develop Web
sites, access databases, work with legacy COM and COM+ objects, develop Windows
desktop applications, work with various .NET Framework concepts, and more.
The primary focus of this book is .NET development using C# as the implementation
language and the .NET Framework's C# command-line compiler as the primary development
tool. C# development using the Visual Studio .NET tool is not covered in this book, although
the task of using Visual Studio .NET to develop C# applications can be easily mastered once
the fundamentals of .NET development using C# are well understood.
Who Should Read This Book
This book was written with both the novice and experienced developer in mind. If you know
nothing at all about the basics of software development, this book will get you started with the
fundamentals, teaching you how variables, control loops, and classes work. The book will
also speak to developers of any skill level, showing you the .NET tools available for C#
development and providing you with tips to make your own C# applications work seamlessly
within the .NET Framework development guidelines.
If you already have delved into the world of creating .NET applications, you will find this
book a useful resource, because it covers almost every aspect of .NET development in depth.
The first three parts of the book serve as an illustrative reference to using features of the C#
language. By contrast, the final two portions of the book are dedicated to showcasing C# as an
application development platform, illustrating the role of C# in desktop-, Web-, database-,
and component-based applications.
This book assumes that you are seeing C# for the very first time and aims to provide an
understanding of the language without requiring any previous language expertise. The book
does assume, however, that you are familiar with the application environments used in
conjunction with your C# applications. The final portions of this book cover the use of C#
with desktop, Web, database and component applications, but does not explain those
platforms in detail. Rather, the book assumes that you have a working knowledge of those
application platforms.
[ Pobierz całość w formacie PDF ]