Chapter 14 - Basic Windows Programming Chapter 15 - Advanced Windows Forms Features Chapter 16 - Using Common Dialogs... This book covers everything you need to know about Visual C# 2005
Trang 1Chapter 10 - Defining Class Members
Chapter 11 - Collections, Comparisons, and
Conversions Chapter 12 - Generics
Chapter 13 - Additional OOP Techniques
Trang 2Chapter 14 - Basic Windows Programming
Chapter 15 - Advanced Windows Forms Features Chapter 16 - Using Common Dialogs
Trang 3Creating next-generation software and applications is now easier than ever with the release of Visual C#
2005 This accessible book guides you through all
aspects of C# programming and the capabilities of
Visual Studio 2005 so that you can begin developing customized applications.
You'll first learn all aspects of the C# language, from the fundamentals to object-oriented techniques You'll then quickly progress through Windows and Web
programming to making use of data sources, and
finally to some advanced techniques such as XML
documentation and graphics programming with GDI+ Throughout the book, you'll also find helpful hints, tips, exercises, and full-fledged example code that will
enhance your programming skills.
This book covers everything you need to know about Visual C# 2005 and the NET Framework to create
powerful, secure applications for mobile devices, Web applications, Windows applications, and Web services What you will learn from this book
Ways to add functionality to your Visual C#
applications
How to publish applications to the Web with the click of a button
Techniques for assembling advanced Windows
applications with a minimum of effort and time
Trang 4Tips for using Web services to add complex data and functionality to Web applications
Trang 6No part of this publication may be reproduced, stored in a retrievalsystem 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 StatesCopyright Act, without either the prior written permission of the
copy fee to the Copyright Clearance Center, 222 Rosewood Drive,Danvers, MA 01923, (978) 750-8400, fax (978) 646-8600 Requests tothe Publisher for permission should be addressed to the Legal
IS REQUIRED, THE SERVICES OF A COMPETENT
PROFESSIONAL PERSON SHOULD BE SOUGHT NEITHER THEPUBLISHER NOR THE AUTHOR SHALL BE LIABLE FOR
DAMAGES ARISING HEREFROM THE FACT THAT AN
ORGANIZATION OR WEBSITE IS REFERRED TO IN THIS WORK
AS A CITATION AND/OR A POTENTIAL SOURCE OF FURTHERINFORMATION DOES NOT MEAN THAT THE AUTHOR OR THEPUBLISHER ENDORSES THE INFORMATION THE
ORGANIZATION OR WEBSITE MAY PROVIDE OR
Trang 7SHOULD BE AWARE THAT INTERNET WEBSITES LISTED IN
THIS WORK MAY HAVE CHANGED OR DISAPPEARED
BETWEEN WHEN THIS WORK WAS WRITTEN AND WHEN IT ISREAD
For general information on our other products and services pleasecontact our Customer Care Department within the United States at(800) 762-2974, outside the United States at (317) 572-3993 or fax(317) 572-4002
Trademarks: Wiley, the Wiley logo, Wrox, the Wrox logo,
Programmer to Programmer, and related trade dress are trademarks
or registered trademarks of John Wiley & Sons, Inc and/or its
affiliates, in the United States and other countries, and may not beused without written permission Visual C# is a registered trademark
of Microsoft Corporation in the United States and/or other countries.All other trademarks are the property of their respective owners WileyPublishing, Inc., is not associated with any product or vendor
mentioned in this book
Wiley also publishes its books in a variety of electronic formats Somecontent that appears in print may not be available in electronic books
Trang 9I'd like to dedicate my portion of this book to my wife, Beth, and our children Nathaniel, Timothy, and Walter Thanks for your support and encouragement Also a big thank you to my co-authors and the team
accessible to anyone with a passion to learn, and spends much of histime playing with new technology to find new things to teach peopleabout
During those (seemingly few) times where he isn't doing the above,Karli will probably be wishing he was hurtling down a mountain on asnowboard Or possibly trying to get his novel published Either way,you'll know him by his brightly colored clothes
Christian Nagel is a software architect, trainer, and consultant, and
an associate of Thinktecture, offering training and coaching based onMicrosoft NET technologies His achievements in the developer
community have earned him a position as Microsoft Regional Directorand MVP for Visual C# He enjoys an excellent reputation as an
http://www.christiannagel.com
Trang 10Jacob Hammer Pedersen is a systems developer at Fujitsu Service,
Denmark He's been programming the PC since the early 90s usinglanguages such as Pascal, Visual Basic, C/C++, and in later yearsC# Jacob is an MCSD who works almost exclusively on the Microsoftplatform where his expertise includes NET, COM, COM+/EnterpriseServices, SQL Server, and MS Office development A Danish citizen,
Morgan Skinner began his computing career at a tender age on a
Sinclair ZX80 at school, where he was underwhelmed by some code
a teacher had written and so began programming in assembly
language After getting hooked on Z80 (which he believes is far betterthan those paltry 3 registers on the 6502), he graduated through theschool's ZX81s to his own ZX Spectrum
Since then he's used all sorts of languages and platforms, includingVAX Macro Assembler, Pascal, Modula2, Smalltalk, X86 assemblylanguage, PowerBuilder, C/C++, VB, and currently C# He's beenprogramming in NET since the PDC release in 2000, and liked it somuch, he joined Microsoft in 2001 He now works in Premier Supportfor Developers and spends most of his time assisting customers withC#
You can reach Morgan at http://www.morganskinner.com
Eric White is an independent software consultant with over 20 years
experience in building management information systems and
Trang 11programming in C#, he will most likely be found with an ice axe inhand, climbing some mountain
Trang 12C# is a relatively new language that was unveiled to the world whenMicrosoft released the first version of its NET Framework Since thenits popularity has rocketed, and it has arguably become the language
of choice for both Windows and Web developers who use NET Part
of the appeal of C# comes from its clear syntax, which derives fromC/C++, but simplifies some things that have previously discouragedsome programmers Despite this simplification, C# has retained thepower of C++, and there is now no reason not to move into C# Thelanguage is not difficult, and is an excellent one to learn elementaryprogramming techniques with This ease of learning, combined withthe capabilities of the NET Framework, make C# an excellent way tostart your programming career
The latest release of C#, part of NET 2.0, builds on the existing
successes and adds even more attractive features Some of these,again, have their roots in C++—at least superficially—but some areentirely new The latest release of Visual Studio also brings manytweaks and improvements to make your life easier and dramaticallyincrease your productivity
This book is intended to teach you about all aspects of C#
programming, from the language itself, through Windows and Webprogramming, to making use of data sources, and finally to some
advanced techniques such as graphics programming You'll also learnabout the capabilities of Visual Studio 2005 and all the ways that itcan aid your application development The book is written in a friendly,mentor-style fashion, where each chapter builds on previous ones andevery effort is made to ease you into advanced techniques painlessly
At no point will technical terms appear from nowhere to discourageyou from continuing; every concept is introduced and discussed asrequired Technical jargon is kept to a minimum, but where it is
necessary, it too will be properly defined and laid out in context
The authors of this book are all experts in their field, and are all
enthusiastic in their passion for both the C# language and the NETFramework Nowhere will you find a group of people better qualified to
Trang 13fundamental knowledge it provides, this book is packed full of helpfulhints, tips, exercises, and fully-fledged example code (available fordownload at p2p.wrox.com) that you will find yourself using timeand again as your career progresses
We pass this knowledge on without begrudging it, and hope that youwill be able to use it to become the best programmer you can be.Good luck, and all the best!
Trang 14This book is for everyone who wants to learn how to program in C#using the NET Framework The early chapters cover the languageitself, assuming no prior programming experience If you have
programmed in other languages before, then much of the material inthese chapters will be familiar Many aspects of C# syntax are sharedwith other languages, and many structures are common to practicallyall programming languages (such as looping and branching
structures) However, even if you are an experienced programmer youwill benefit from looking through these chapters to learn the specifics
of how these techniques apply to C#
If you are new to programming, you should start from the beginning Ifyou are new to NET but know how to program, you should read
Chapter 1 and then skim through the next few chapters before getting
on to the application of the C# language If you know how to programbut haven't encountered an object oriented programming languagebefore, you should read the chapters from Chapter 8 onward
Alternatively, if you already know the C# language you may wish toconcentrate on the chapters dealing with NET 2.0 changes,
specifically the chapters on Collections and Generics (Chapters 11
and 12), or skip the first section of the book completely and start with
Chapter 14
The chapters in this book are written with a dual purpose in mind:They can be read sequentially to provide a complete tutorial in the C#language, and they can be dipped into as required as a referencematerial
In addition to the core material, each chapter also includes a selection
of exercises that you can work through to ensure that you have
understood the material taught The exercises range from simple
multiple choice or true/false questions to more involved questions thatrequire you to modify or build applications The answers to all the
Trang 15exercises are provided online at p2p.wrox.com.
Trang 16ways of using C# and the NET Framework, including
assemblies, attributes, XML documentation, networking, andgraphics programming with GDI+
along the way you'll be introduced to the VS development
Trang 17throughout the book
Next you'll learn more about the basics of the C# language You'lllearn what variables are and how to manipulate them in Chapter 3
You'll enhance the structure of your applications with flow control
(looping and branching) in Chapter 4 , and see some more advanced
variable types such as arrays in Chapter 5 In Chapter 6 you'll start toencapsulate your code in the form of functions, which make it mucheasier to perform repetitive operations and make your code muchmore readable
By the start of Chapter 7 you'll have a handle on the fundamentals ofthe C# language, and will focus on debugging your applications Thisinvolves looking at outputting trace information as your applicationsare executed, and at how VS can be used to trap errors and lead you
to solutions for them with its powerful debugging environment
From Chapter 8 onward you'll learn about Object-Oriented
Programming (OOP), starting with a look at what this term means,and an answer to the eternal question "What is an object?" OOP canseem quite difficult at first The whole of Chapter 8 is devoted to
demystifying it and explaining what makes it so great, and you won'tactually be dealing with much C# code until the very end of the
Trang 18Windows Programming (Chapters 14–17)
Chapter 14 starts by introducing you to what is meant by Windowsprogramming, and looks at how this is achieved in VS Again, you'llstart with the basics and build up your knowledge over this chapterand in Chapter 15 , seeing how you can use the wealth of controls
supplied by the NET Framework in your applications You'll quicklyunderstand how NET enables you to build Windows applications in agraphical way, and assemble advanced applications with the minimum
Web Programming (Chapters 18–21)
This section is structured in a similar way to the Windows
programming section It starts with Chapter 18 describing the controls
that make up the simplest of Web applications, and how you can fitthem together and make them perform tasks using ASP.NET Chapter
19 builds on this and introduces more advanced techniques, versatilecontrols, and state management in the context of the Web, as well asconforming to Web standards
Chapter 20 is an excursion into the wonderful world of Web services,which are set to revolutionize the way people use the Internet Webservices enable you to expose complex data and functionality to Weband windows applications in a platform-independent way This chapterdiscusses how to use and create Web services, and the additionaltools that NET provides, including security
Trang 19In Chapter 23 you'll learn about what is fast becoming the de-factostandard for data exchange, namely XML You'll have touched onXML at several times in preceding chapters, but in this chapter you'lllay out the ground rules and see what all the excitement is about Thiswill be put into practice straight away in Chapter 24 , where you'll see
how to use ADO.NET to interact with databases ADO.NET includestechniques to deal with XML, and much more
Chapter 25 will then show you some excellent ways to make use ofADO.NET in your applications via data binding, which is a great way
to simplify database access—especially since it requires little effort onyour part to provide a user interface to data
Additional Techniques (Chapters 26–30)
In the last section of the book you'll look at a wide variety of additionalC# and NET subjects In Chapter 26 you'll learn more about NETassemblies, the basic building blocks of all sorts of NET applications
In Chapter 27 you'll look at attributes, a powerful way to both includeadditional information about types in assemblies, and add functionalitythat would otherwise be difficult to implement
Chapter 28 deals with XML documentation and how you can
document your applications at the source code level You'll see how toadd this information and how to use and extract it You'll take this to
Trang 20Next you'll look at networking in Chapter 29 , and how your
applications can communicate with each other and with other servicesacross various types of networks Finally, Chapter 30 comes almost
as a bit of light relief from many of the involved techniques you'll haveseen earlier in the book by covering the subject of graphics
programming with GDI+ You'll learn how to manipulate graphics andstyle your applications, opening the door to a vast array of C#
applications and having a bit of fun along the way
Trang 21The code and descriptions of C# and the NET Framework in thisbook apply to NET 2.0 You don't need anything other than the
Framework to understand this aspect of the book, but many of theexamples require Visual Studio 2005 (VS) There is also quite a lot ofexplanation of the VS development environment which may not apply
to other tools, such as Visual C# 2005 Express
Trang 23The gray highlighting is not used for code that's less important in the presentcontext, or has been shown before
Trang 24As you work through the examples in this book, you may chooseeither to type in all the code manually or to use the source code filesthat accompany the book All of the source code used in this book isavailable for download at http://www.wrox.com Once at the site,simply locate the book's title (either by using the Search box or byusing one of the title lists) and click the Download Code link on thebook's detail page to obtain all the source code for the book
NoteBecause many books have similar titles, you may find it
7847-2
easiest to search by ISBN; for this book the ISBN is 0-7645-Once you download the code, just decompress it with your favoritecompression tool Alternately, you can go to the main Wrox codedownload page at
http://www.wrox.com/dynamic/books/download.aspx tosee the code available for this book and all other Wrox books
Trang 25We make every effort to ensure that there are no errors in the text or
in the code However, no one is perfect, and mistakes do occur If youfind an error in one of our books, like a spelling mistake or faulty piece
of code, we would be very grateful for your feedback By sending inerrata you may save another reader hours of frustration and at thesame time you will be helping us provide even higher quality
information
To find the errata page for this book, go to http://www.wrox.com
and locate the title using the Search box or one of the title lists Then,
on the book details page, click the Book Errata link On this page youcan view all errata that has been submitted for this book and posted
by Wrox editors A complete book list including links to each's book'serrata is also available at www.wrox.com/misc-
pages/booklist.shtml
If you don't spot "your" error on the Book Errata page, go to
www.wrox.com/contact/techsupport.shtml and complete theform there to send us the error you have found We'll check the
information and, if appropriate, post a message to the book's erratapage and fix the problem in subsequent editions of the book
Trang 26For author and peer discussion, join the P2P forums at
p2p.wrox.com The forums are a Web-based system for you topost messages relating to Wrox books and related technologies andinteract with other readers and technology users The forums offer asubscription feature to e-mail you topics of interest of your choosingwhen new posts are made to the forums Wrox authors, editors, otherindustry experts, and your fellow readers are present on these forums
At http://p2p.wrox.com you will find a number of different forumsthat will help you not only as you read this book, but also as you
develop your own applications To join the forums, just follow thesesteps:
1 Go to p2p.wrox.com and click the Register link
2 Read the terms of use and click Agree
3 Complete the required information to join as well as anyoptional information you wish to provide and click Submit
4 You will receive an e-mail with information describing how toverify your account and complete the joining process
NoteYou can read messages in the forums without
joining P2P but in order to post your ownmessages, you must join
Once you join, you can post new messages and respond to messagesother users post You can read messages at any time on the Web Ifyou would like to have new messages from a particular forum e-
mailed to you, click the Subscribe to this Forum icon by the forumname in the forum listing
For more information about how to use the Wrox P2P, be sure to readthe P2P FAQs for answers to questions about how the forum softwareworks as well as many common questions specific to P2P and Wroxbooks To read the FAQs, click the FAQ link on any P2P page
Trang 27Part I: The C# Language
Trang 29Chapter 1: Introducing C#
Trang 30Welcome to the first chapter of the first section of this book Over thecourse of this section, you look at the basic knowledge required to get
up and running with C# In this first chapter, you get an overview of C#and the NET Framework, and you consider what these technologiesare, the motivation for using them, and how they relate to each other.You start with a general discussion of the NET Framework This isstill a new technology and contains many concepts that are tricky tocome to grips with at first (mainly because the Framework introduces
a new way of doing things to application development) This meansthat the discussion will, by necessity, cover many new concepts in ashort space of time However, a quick look at the basics is essential tounderstand how to program in C#, so this is a necessary evil Later inthe book you will revisit many of the topics covered here in more
detail
After this general discussion, you move on to a simple description ofC# itself, including its origins and similarities to C++ Finally, you look
at the primary tool used throughout this book: Visual Studio 2005
(VS)
Trang 31the NET Framework is a new and revolutionary platform created byMicrosoft for developing applications
The most interesting thing about this statement is how vague I've
been — but there are good reasons for this For a start, note that Ididn't say "developing applications on the Windows operating
system." Although the Microsoft release of the NET Framework runs
on the Windows operating system, it is fast becoming possible to findalternative versions that will work on others One example of this isMono, an open source version of the NET Framework (including a C#compiler) that will run on several operating systems, including variousflavors of Linux and Mac OS More such projects are in the pipelineand may be available by the time you read this In addition, you canuse the Microsoft NET Compact Framework (essentially a subset ofthe full NET Framework) on personal digital assistant (PDA) classdevices and even some smartphones One of the key motivationalforces behind the NET Framework is its intended use as a means ofintegrating disparate operating systems
In addition, the definition of the NET Framework given above includes
no restriction on the type of applications that are possible This is
because there is no restriction — the NET Framework allows thecreation of Windows applications, Web applications, Web services,and pretty much anything else you can think of
the NET Framework has been designed so that it can be used fromany language This includes the subject of this book, C#, as well asC++, Visual Basic, JScript, and even older languages such as
COBOL For this to work, NET-specific versions of these languageshave also appeared, and more are being released all the time Notonly do all of these have access to the NET Framework, but they canalso communicate with each other It is perfectly possible for C#
developers to make use of code written by Visual Basic programmers,and vice versa
All of this provides a hitherto unthinkable level of versatility and is part
Trang 32prospect
What's in the NET Framework?
the NET Framework consists primarily of a gigantic library of codethat you use from your client languages (such as C#) using object-oriented programming (OOP) techniques This library is categorizedinto different modules — you use portions of it depending on the
results you want to achieve For example, one module contains thebuilding blocks for Windows applications, another for network
programming, and another for Web development Some modules aredivided into more specific submodules, such as a module for buildingWeb services within the module for Web development
The intention here is for different operating systems to support some
or all of these modules, depending on their characteristics A PDA, forexample, would include support for all the core NET functionality, but
is unlikely to require some of the more esoteric modules
Part of the NET Framework library defines some basic types A type
is a representation of data, and specifying some of the most
fundamental of these (such as "a 32-bit signed integer") facilitatesinteroper- ability between languages using the NET Framework This
is called the the Common Type System (CTS).
As well as supplying this library, the Framework also includes the
.NET Common Language Runtime (CLR), which is responsible for
maintaining the execution of all applications developed using the NETlibrary
How Do I Write Applications Using the NET Framework?
Writing an application using the NET Framework means writing code(using any of the languages that support the Framework) using the.NET code library In this book you use VS for your development —
VS is a powerful, integrated development environment that supportsC# (as well as managed and unmanaged C++, Visual Basic, and
Trang 33In order for C# code to execute, it must be converted into a language
that the target operating system understands, known as native code This conversion is called compiling code, an act that is performed by a
compiler Under the NET Framework, however, this is a two-stage
process
MSIL and JIT
When you compile code that uses the NET Framework library, youdon't immediately create operating system–specific native code
Instead, you compile your code into Microsoft Intermediate Language
(MSIL) code This code isn't specific to any operating system and isn't
specific to C# Other NET languages — for example, Visual Basic.NET — also compile to this language as a first stage This
compilation step is carried out by VS when you use it to develop C#applications
Obviously, to execute an application more work is necessary This is
the job of a Just-in-Time (JIT) compiler, which compiles MSIL into
native code that is specific to the OS and machine architecture beingtargeted Only at this point can the OS execute the application the
just-in-time part of the name here reflects the fact that MSIL code is
only compiled as and when it is needed
In the past, it was often necessary to compile your code into severalapplications, each of which targeted a specific operating system andCPU architecture Often, this was a form of optimization (to get code
to run faster on an AMD chipset, for example), but at times it was
critical (for applications to work in both Win9x and WinNT/2000
environments, for example) This is now unnecessary, because JITcompilers (as their name suggests) use MSIL code, which is
independent of the machine, operating system, and CPU Several JIT
Trang 34(that is, information about the information contained in the assembly,
also known as metadata) and optional resources (additional data used
by the MSIL, such as sound files and pictures) The meta informationallows assemblies to be fully self-descriptive You need no other
information to use an assembly, meaning that you avoid situationssuch as failing to add required data to the system registry and so on,which was often a problem when developing with other platforms.This means that deploying applications is often as simple as copyingthe files into a directory on a remote computer Since no additionalinformation is required on the target systems, you can just run an
executable file from this directory and (assuming the NET CLR isinstalled) away you go
Of course, you won't necessarily want to include everything required
to run an application in one place You might write some code thatperforms tasks required by multiple applications In situations like this,
Trang 35The role of the CLR doesn't end once you have compiled your code toMSIL, and a JIT compiler has compiled this to native code Code
written using the NET Framework is managed when it is executed (this stage is usually referred to as being at runtime) This means that
the CLR looks after your applications by managing memory, handlingsecurity, allowing cross-language debugging, and so on By contrast,applications that do not run under the control of the CLR are said to
be unmanaged and certain languages such as C++ can be used to
write such applications that, for example, access low-level functions ofthe operating system However, in C# you can write only code thatruns in a managed environment You will make use of the managedfeatures of the CLR and allow NET itself to handle any interactionwith the operating system
of being allocated to the wrong place in memory This usually meant aprogressive slowdown of your computer followed by a system crash NET garbage collection works by inspecting the memory of your
computer every so often and removing anything from it that is no
longer needed There is no set timeframe for this; it might happenthousands of times a second, once every few seconds, or whenever,but you can rest assured that it will happen
There are some implications for programmers here Since this work isdone for you at an unpredictable time applications have to be
designed with this in mind Code that requires a lot of memory to runshould tidy itself up rather than waiting for garbage collection to
happen, but this isn't anything like as tricky as it sounds
Trang 36Before moving on, I'll summarize the steps required to create a NETapplication as discussed previously:
Trang 37useful The reason for this is that it is far easier to work with severalsmaller files than one enormous one You can separate out logicallyrelated code into an individual file, so that it can be worked on
independently and then practically forgotten about when completed.This also makes it much easier to locate specific pieces of code whenyou need them and enables teams of developers to divide up theprogramming burden into manageable chunks, where individuals can
"check out" pieces of code to work on without risking damage to
otherwise satisfactory sections or sections that other people are
working on
Trang 38C#, as mentioned earlier, is one of the languages that can be used tocreate applications that will run in the NET CLR It is an evolution ofthe C and C++ languages and has been created by Microsoft
specifically to work with the NET platform Because it is a recent
development, the C# language has been designed with hindsight,taking into account many of the best features from other languages,while clearing up their problems
Developing applications using C# is simpler than using C++, becausethe language syntax is simpler However, C# is a powerful language,and there is little you might want to do in C++ that you can't do in C#.Having said that, those features of C# that parallel the more advancedfeatures of C++, such as directly accessing and manipulating system
memory, can only be carried out using code marked as unsafe This
advanced programmatic technique is potentially dangerous (hence itsname), because it is possible to overwrite system-critical blocks ofmemory with potentially catastrophic results For this reason, andothers, this book will not cover this topic
At times, C# code is slightly more verbose than C++ This is a
consequence of C# being a type-safe language (unlike C++) In
layperson's terms, this means that once some data has been
assigned to a type, it cannot subsequently transform itself into anotherunrelated type Consequently, there are strict rules that must be
adhered to when converting between types, which means that you willoften need to write more code to carry out the same task in C# thanyou might write in C++, but you get the benefits that code is morerobust and debugging is simpler — NET can always track what type apiece of data is at any time In C#, you therefore may not be able to
do things such as "take the region of memory 4 bytes into this dataand 10 bytes long and interpret it as X," but that's not necessarily abad thing
C# is just one of the languages available for NET development, but in
my opinion it is certainly the best It has the advantage of being theonly language designed from the ground up for the NET Framework
Trang 39predecessors yet compliant with the CLR, certain features of the NETcode library are not fully supported By contrast, C# is able to makeuse of every feature that the NET Framework code library has tooffer The latest version of NET includes several improvements to theC# language, partly in response to requests from developers, making
it even more powerful
What Kind of Applications Can I Write with C#?
the NET Framework has no restrictions on the types of applicationsthat are possible, as discussed earlier C# uses the Framework and
so also has no restrictions on possible applications However, hereare a few of the more common application types:
Windows Applications: These are applications, such as
Microsoft Office, which have a familiar Windows look and feelabout them This is made simple by using the Windows Forms
module of the NET Framework, which is a library of controls
(such as buttons, toolbars, menus, and so on) that you canuse to build a Windows user interface (UI)
Web Applications: These are Web pages such as might be
viewed through any Web browser the NET Framework
includes a powerful system of generating Web content
dynamically, allowing personalization, security, and muchmore This system is called ASP.NET (Active Server Pages.NET), and you can use C# to create ASP.NET applicationsusing Web Forms
Web Services: These are a new and exciting way of creating
versatile distributed applications Using Web services you canexchange virtually any data over the Internet, using the samesimple syntax regardless of the language used to create aWeb service or the system that it resides on
Trang 40.NET) section of the NET Framework Many other resources can bedrawn on, such as tools for creating networking components,
outputting graphics, performing complex mathematical tasks, and soon
C# in This Book
The first section of this book deals with the syntax and usage of theC# language without too much emphasis on the NET Framework.This is necessary, because you won't be able to use the NET
Framework at all without a firm grounding in C# programming Youstart off even simpler, in fact, and leave the more involved topic ofobject-oriented programming (OOP) until you've covered the basics.These will be taught from first principles, assuming no programmingknowledge at all
Once you have done this, you will be ready to move on to developingthe types of application listed in the last section Section two of thisbook will look at Windows Forms programming, Section three will look
at Web application and Web service programming, Section four willexamine data access (for database, file system and XML data), andSection five covers some other NET topics of interest (such as moreabout assemblies and graphics programming)