1. Trang chủ
  2. » Công Nghệ Thông Tin

Wrox professional c sharp 2005 nov 2005 ISBN 0764575341

768 70 0

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

THÔNG TIN TÀI LIỆU

Thông tin cơ bản

Định dạng
Số trang 768
Dung lượng 19,01 MB

Nội dung

Next Page Professional C# 2005 byC hristian Nagelet al Wrox Press 2006 (1586 pages) ISBN:0764575341 Updated for NET Fram ework 2.0 and Visual Studio 2005, this thorough tex t will help you gain a well-rounded understanding of C# so you can begin program m ing lik e an ex pert right away Table of Contents Professional C # 2005 Introduction Part I - The C# Language C hapter - NET Architecture C hapter - C # Basics C hapter - Objects and Types C hapter - Inheritance C hapter - Operators and C asts C hapter - Delegates and Events C hapter - Memory Management and Pointers C hapter - Strings and Regular Expressions C hapter - C ollections C hapter 10 - Generics C hapter 11 - Reflection C hapter 12 - Errors and Exceptions C hapter 13 - Threading Part II - The NET Environment C hapter 14 - Visual Studio 2005 C hapter 15 - Assemblies C hapter 16 - NET Security C hapter 17 - Localization C hapter 18 - Deployment Part III - Data C hapter 19 - Data Access with NET C hapter 20 - NET Programming with SQL Server 2005 C hapter 21 - Manipulating XML C hapter 22 - Working with Active Directory Part IV - Windows Applications C hapter 23 - Windows Forms C hapter 24 - Viewing NET Data C hapter 25 - Graphics with GDI+ Part V - Web Applications C hapter 26 - ASP.NET Pages C hapter 27 - ASP.NET Development Part VI - Communication C hapter 28 - Web Services C hapter 29 - NET Remoting C hapter 30 - Enterprise Services C hapter 31 - Message Queuing C hapter 32 - Future of Distributed Programming Part VII - Interop C hapter 33 - C OM Interoperability Part VIII - Windows Base Services C hapter 34 - Manipulating Files and the Registry C hapter 35 - Accessing the Internet C hapter 36 - Windows Services Part IX - Appendices Appendix A - Principles of Object- Oriented Programming Appendix B - C # for Visual Basic Developers Appendix C - C # for Java Developers Appendix D - C # for C ++ Developers Index List of Figures Next Page Next Page Back Cover C # and NET are set to revolutionize the way that you write programs Updated for NET Framework 2.0 and Visual Studio 2005, this bestselling book will give you the tools to program in C #, while also providing you with the necessary background in how the NET architecture works You'll first explore the fundamentals of C #, including its basic syntax, data types, and object-oriented features You'll then discover how to apply the language to a number of innovative applications that use related technologies, including database access and advanced graphics This approach will help you gain a well-rounded understanding of C # so that you can begin programming like an expert right away This book covers everything you need to know in order to write dynamic Web pages, an XML Web service, a component of a distributed application, a classic Windows desktop application, and much more What you will learn from this book The principles of programming in the NET environment Ways to create Windows applications and Windows services How to use existing C OM components with NET applications Steps for writing dynamic Web pages and Web services with ASP.NET Techniques for manipulating XML using C # 2005 How to access databases with ADO.NET and interact with directories Tips for writing cutting-edge components that will run on Web sites Who this book is for This book is for the experienced developer, although no previous knowledge of C # or NET programming is assumed It is also for programmers who know NET 1.0 and are interested in getting up to speed with NET 2.0 and Visual Studio 2005 Next Page Next Page Professional C# 2005 Christian Nagel Bill Evjen Jay Glynn Karli Watson Morgan Skinner Allen Jones Published by Wiley Publishing, Inc 10475 Crosspoint Boulevard Indianapolis, IN 46256 www.wiley.com Copyright 2006 by Wiley Publishing, Inc., Indianapolis, Indiana Published simultaneously in Canada Library of Congress Card Number: 2005048978 ISBN-13: 978-0-7645-7534-1 ISBN-10: 0-7645-7534-1 10 1B/SQ/RQ/QV/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 Section 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, Inc., 222 Rosewood Drive, Danvers, MA 01923, (978) 750-8400, fax(978) 646-8600 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-4355 or online at http://www.wiley.com/go/permissions LIMIT OF LIABILITY/DISCLAIMER OF WARRANTY: THE PUBLISHER AND THE AUTHOR MAKE NO REPRESENTATIONS OR WARRANTIES WITH RESPECT TO THE ACCURACY OR COMPLETENESS OF THE CONTENTS OF THIS WORK AND SPECIFICALLY DISCLAIM ALL WARRANTIES, INCLUDING WITHOUT LIMITATION WARRANTIES OF FITNESS FOR A PARTICULAR PURPOSE NO WARRANTY MAY BE CREATED OR EXTENDED BY SALES OR PROMOTIONAL MATERIALS THE ADVICE AND STRATEGIES CONTAINED HEREIN MAY NOT BE SUITABLE FOR EVERY SITUATION THIS WORK IS SOLD WITH THE UNDERSTANDING THAT THE PUBLISHER IS NOT ENGAGED IN RENDERING LEGAL, ACCOUNTING, OR OTHER PROFESSIONAL SERVICES IF PROFESSIONAL ASSISTANCE IS REQUIRED, THE SERVICES OF A COMPETENT PROFESSIONAL PERSON SHOULD BE SOUGHT NEITHER THE PUBLISHER NOT 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 FURTHER INFORMATION DOES NOT MEAN THAT THE AUTHOR OR THE PUBLISHER ENDORSES THE INFORMATION THE ORGANIZATION OR WEBSITE MAY PROVIDE OR RECOMMENDATIONS IT MAY MAKE FURTHER, READERS SHOULD BE AWARE THAT INTERNET WEBSITES LISTED IN THIS WORK MAY HAVE CHANGED OR DISAPPEARED BETWEEN WHEN THIS WORK WAS WRITTEN AND WHEN IT IS READ For general information on our other products and services please contact our Customer Care Department within the United States at (800) 762-2974, outside the United States at (317) 5723993 or fax (317) 572-4002 Trademarks: Wiley, the Wiley Publishing logo, Wrox, the Wrox logo, and Programmer to Programmer are trademarks or registered trademarks of John Wiley & Sons, Inc and/or its affiliates 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 Wiley also publishes its books in a variety of electronic formats Some content that appears in print may not be available in electronic books About the Authors Christian Nagel Christian Nagel is software architect and developer, associate of Thinktecture, who offers training and consulting on how to design and develop Microsoft NET solutions He looks back to more than 15 years' experience as a developer and software architect Christian started his computing career with PDP 11 and VAX/VMS platforms, covering a variety of languages and platforms Since the year 2000 — when NET was just a technology preview — he has been working with various NET technologies to build distributed solutions With his profound knowledge of Microsoft technologies, he has also written numerous NET books; is certified as Microsoft Certified Trainer (MCT), Solution Developer (MCSD), and Systems Engineer (MCSE); and is Microsoft Regional Director and MVP for Visual C# Christian is a speaker at international conferences (TechED, DevDays, VCDC) and is the regional manager of INETA Europe (International NET User Group Association) supporting NET user groups You can contact Christian via his Web site,http://www.christiannagel.com and http://www.thinktecture.com Bill Evjen Bill Evjen is an active proponent of the NET technologies and community-based learning initiatives for.NET He has been actively involved with NET since the first bits were released in 2000 and has since become president of the St Louis NET User Group (http://www.stlusergroups.org) Bill is also the founder and executive director of the International NET Association (http://www.ineta.org), which represents more than 125,000 members worldwide Based in St Louis, Missouri, USA, Bill is an acclaimed author and speaker on ASP.NET and XML Web services He has written XML Web Services for ASP.NET, Web Services Enhancements: Understanding the WSE for Enterprise Applications, Visual Basic NET Bible, and ASP.NET Professional Secrets (all published by Wiley) Bill is a Technical Director for Reuters, the international news and financial services company He graduated from Western Washington University in Bellingham, Washington, with a Russian language degree You can reach Bill at evjen@yahoo.com Jay Glynn Jay Glynn started writing software nearly 20 years ago, writing applications for the PICK operating system using PICK basic Since then, he has created software using Paradox PAL and Object PAL, Delphi, VBA, Visual Basic, C, C++, Java, and of course C# He is currently a Project Coordinator and Architect for a large financial services company in Nashville, Tennessee, working on software for the TabletPC platform He can be contacted at jlsglynn@hotmail.com Karli Watson Karli Watson is a freelance author and the technical director of 3form Ltd (http://www.3form.net) Despite starting out by studying nanoscale physics, the lure of cold, hard cash proved too much and dragged Karli into the world of computing He has since written numerous books on NET and related technologies, SQL, mobile computing, and a novel that has yet to see the light of day (but that doesn't have any computers in it) Karli is also known for his multicolored clothing, is a snowboarding enthusiast, and still wishes he had a cat Morgan Skinner 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 better than those paltry registers on the 6502), he graduated through the school's ZX81s to his own ZX Spectrum Since then he's used all sorts of languages and platforms, including VAX Macro Assembler, Pascal, Modula2, Smalltalk, X86 assembly language, PowerBuilder, C/C++, VB, and currently C# He's been programming in NET since the PDC release in 2000, and liked it so much he joined Microsoft in 2001 He now works in Premier Support for Developers and spends most of his time assisting customers with C# You can reach Morgan at http://www.morganskinner.com Allen Jones Allen Jones has a career spanning 15 years that covers a broad range of IT disciplines, including enterprise management, solution and enterprise architecture, and project management But software development has always been Allen's passion Allen has architected and developed Microsoft Windows-based solutions since 1990, including a variety of e-commerce, trading, and security systems Allen has co-authored four popular NET books including the C# Programmer's Cookbook (Microsoft Press) and Programming NET Security (O'Reilly), and he is actively involved in the development of courseware for Microsoft Learning covering emerging NET technologies Credits Vice President and Executive Group Publisher Richard Swadley Vice President and Executive Publisher Joseph B Wikert Acquisitions Editor Katie Mohr Editorial Manager Mary Beth Wakefield Production Manager Tim Tate Development Editor Sharon Nash Production Editor Angela Smith Technical Editor Brian Patterson Project Coordinator Michael Kruzil Graphics and Production Specialists Andrea Dahl Carrie Foster Lauren Goddard Denny HagerJoyce Haughey Alicia B South Julie Trippetti Quality Control Technicians Leeann Harney Carl William Pierce Brian H Walls Proofreading and Indexing TECHBOOKS Production Services To Kalle — Welcome to the family! — Bill Evjen First, I want to thank everyone at Wrox and Microsoft that helped in getting this done Also, I'd like to thank the other authors for their hard work Finally, I would like to dedicate this to my wife and my son for putting up with me and the late nights Without their support and love, none of this really matters — Jay Glynn To Donna — Karli Watson For my brother, Michael —Allen Jones Next Page Next Page Introduction If we were to describe the C# language and its associated environment, the NET Framework, as the most important new technology for developers for many years, we would not be exaggerating .NET is designed to provide a new environment within which you can develop almost any application to run on Windows, while C# is a new programming language that has been designed specifically to work with.NET Using C# you can, for example, write a dynamic Web page, an XML Web service, a component of a distributed application, a database access component, a classic Windows desktop application, or even a new smart client application that allows for online/offline capabilities This book covers the NET Framework 2.0, the third release of the framework If you are coding using version 1.0 or 1.1, there may be sections of the book that will not work for you We try to notify you of items that are new to the NET Framework 2.0 specifically Don't be fooled by the NET label The NET bit in the name is there to emphasize Microsoft's belief that distributed applications, in which the processing is distributed between client and server, are the way forward, but C# is not just a language for writing Internet or network-aware applications It provides a means for you to code up almost any type of software or component that you might need to write for the Windows platform Between them, C# and NET are set both to revolutionize the way that you write programs, and to make programming on Windows much easier than it has ever been That's quite a substantial claim, and it needs to be justified After all, we all know how quickly computer technology changes Every year Microsoft brings out new software, programming tools, or versions of Windows, with the claim that these will be hugely beneficial to developers So what's different about.NET and C#? The Significance Of NET And C# In order to understand the significance of NET, it is useful to remind ourselves of the nature of many of the Windows technologies that have appeared in the past ten years or so Although they may look quite different on the surface, all of the Windows operating systems from Windows 3.1 (introduced in 1992) through Windows Server 2003 have the same familiar Windows API at their core As we've progressed through new versions of Windows, huge numbers of new functions have been added to the API, but this has been a process of evolving and extending the API rather than replacing it The same can be said for many of the technologies and frameworks that we've used to develop software for Windows For example, COM (Component Object Model) originated as OLE (Object Linking and Embedding) At the time, it was, to a large extent, simply a means by which different types of Office documents could be linked, so that, for example, you could place a small Excel spreadsheet in your Word document From that it evolved into COM, DCOM (Distributed COM), and eventually COM+ — a sophisticated technology that formed the basis of the way almost all components communicated, as well as implementing transactions, messaging services, and object pooling Microsoft chose this evolutionary approach to software for the obvious reason that it is concerned about backward compatibility Over the years a huge base of third-party software has been written for Windows, and Windows wouldn't have enjoyed the success it has had if every time Microsoft introduced a new technology it broke the existing code base! While backward compatibility has been a crucial feature of Windows technologies and one of the strengths of the Windows platform, it does have a big disadvantage Every time some technology evolves and adds new features, it ends up a bit more complicated than it was before It was clear that something had to change Microsoft couldn't go on forever extending the same development tools and languages, always making them more and more complex in order to satisfy the conflicting demands of keeping up with the newest hardware and maintaining backward compatibility with what was around when Windows first became popular in the early 1990s There comes a point where you have to start with a clean slate if you want a simple yet sophisticated set of languages, environments, and developer tools, which makes it easy for developers to write state-of-the-art software This fresh start is what C# and NET are all about Roughly speaking, NET is a framework—an API— for programming on the Windows platform Along with the NET Framework, C# is a language that has been designed from scratch to work with NET, as well as to take advantage of all the progress in developer environments and in our understanding of object-oriented programming principles that have taken place over the past 20 years Before we continue, we should make it clear that backward compatibility has not been lost in the process Existing programs will continue to work, and NET was designed with the ability to work with existing software Presently, communication between software components on Windows almost entirely takes place using COM Taking account of this, NET does have the ability to provide wrappers around existing COM components so that NET components can talk to them It is true that you don't need to learn C# in order to write code for NET Microsoft has extended C++, provided another new language called J#, and made substantial changes to Visual Basic to turn it into the more powerful language Visual Basic NET, in order to allow code written in either of these languages to target the NET environment These other languages, however, are hampered by the legacy of having evolved over the years rather than having been written from the start with today's technology in mind This book will equip you to program in C#, while at the same time provide the necessary background in how the NET architecture works We will not only cover the fundamentals of the C# language but also go on to give examples of applications that use a variety of related technologies, including database access, dynamic Web pages, advanced graphics, and directory access The only requirement is that you be familiar with at least one other high-level language used on Windows — either C++, Visual Basic, or J++ Advantages of NET We've talked in general terms about how great NET is, but we haven't said much about how it helps to make your life as a developer easier In this section, we'll discuss some of the improved features of NET in brief Object-Oriented Programming — both the NET Framework and C# are entirely based on object-oriented principles right from the start Good Design — a base class library, which is designed from the ground up in a highly intuitive way Language Independence — with NET, all of the languages Visual Basic NET, C#, J#, and managed C++ compile to a common Intermediate Language This means that languages are inter- operable in a way that has not been seen before Better Support for Dynamic Web Pages — while ASP offered a lot of flexibility, it was also inefficient because of its use of interpreted scripting languages, and the lack of object-oriented design often resulted in messy ASP code .NET offers an integrated support for Web pages, using a new technology — ASP.NET With ASP.NET, code in your pages is compiled, and may be written in a NET-aware high-level language such as C#, J#, or Visual Basic 2005 Efficient Data Access — a set of NET components, collectively known as ADO.NET, provides efficient access to relational databases and a variety of data sources Components are also available to allow access to the file system, and to directories In particular, XML support is built into NET, allowing you to manipulate data, which may be imported from or exported to non-Windows platforms Code Sharing — NET has completely revamped the way that code is shared between applications, introducing the concept of the assembly, which replaces the traditional DLL Assemblies have formal facilities for versioning, and different versions of assemblies can exist side by side Improved Security — each assembly can also contain built-in security information that can indicate precisely who or what category of user or process is allowed to call which methods on which classes This gives you a very fine degree of control over how the assemblies that you deploy can be used Zero Impact Installation — there are two types of assembly: shared and private Shared assemblies are common libraries available to all software, while private assemblies are intended only for use with particular software A private assembly is entirely self-contained, so the process of installing it is simple There are no registry entries; the appropriate files are simply placed in the appropriate folder in the file system Support for Web Services — NET has fully integrated support for developing Web services as easily as you'd develop any other type of application Visual Studio 2005 — NET comes with a developer environment, Visual Studio 2005, which can cope equally well with C++, C#, J#, and Visual Basic 2005, as well as with ASP.NET code Visual Studio 2005 integrates all the best features of the respective language-specific environments of Visual Studio NET 2002/2003 and Visual Studio C# — C# is a new object-oriented language intended for use with NET We will be looking more closely at the benefits of the NET architecture in Chapter Next Page Next Page What's New In The NET Framework 2.0 The first version of the NET Framework (1.0) was released in 2002 to much enthusiasm The latest version, the NET Framework 2.0, was introduced in 2005 and is considered a major release of the framework With each release of the framework, Microsoft has always tried to ensure that there were minimal breaking changes to code developed Thus far, they have been very successful at this goal Important Make sure that you create a staging server to completely test the upgrade of your applications to the NET Framework 2.0 as opposed to just upgrading a live application The following details some of the changes that are new to the NET Framework 2.0 as well as new additions to Visual Studio 2005 — the development environment for the NET Framework 2.0 SQL Server integration After a long wait, the latest version of SQL Server has finally been released This version, SQL Server 2005, is quite special in so many ways Most importantly for the NET developer is that SQL Server 2005 is now hosting the CLR Microsoft has developed their NET offering for developers so that the NET Framework 2.0, Visual Studio 2005 and SQL Server 2005 are all now tied together — meaning that these three products are now released in unison This is quite important as it is rather well known that most applications built use all three of these pieces and that they all need to be upgraded together in such a way that they work with each other in a seamless manner Due to the fact that SQL Server 2005 now hosts the CLR, this means that you can now avoid building database aspects of your application using the T-SQL programming language Instead, you can now build items such as your stored procedures, triggers and even data types in any of the NET-compliant languages, such as C# SQL Server Express is the 2005 version of SQL Server that replaces MSDE This version doesn't have the strict limitations MSDE had 64-Bit support Most programming today is done on 32-bit machines It was a monumental leap forward in application development when computers went from 16-bit to 32-bit More and more enterprises are moving to the latest and greatest 64-bit servers from companies such as Intel (Itanium chips) and AMD (x64 chips) and the NET Framework 2.0 has now been 64-bit enabled for this great migration Microsoft has been working hard to make sure that everything you build in the 32-bit world of NET will run in the 64-bit world This means that everything you with SQL Server 2005 or ASP.NET will not be affected by moving to 64-bit Microsoft themselves made a lot of changes to the CLR in order to get a 64- bit version of NET to work Changes where made to things such as garbage collection (to handle larger amounts of data), the JIT compilation process, exception handling, and more Moving to 64-bit gives you some powerful additions The most important (and most obvious reason) is that 64-bit servers give you a larger address space Going to 64-bit also allows for things like larger primitive types For instance, an integer value of 2^32 will give you 4,294,967,296 — while an integer value of 2^64 will give you 18,446,744,073,709,551,616 This comes in quite handy for those applications that need to calculate things such as the U.S debt or other high numbers Companies such as Microsoft and IBM are pushing their customers to take a look at 64-bit One of the main areas of focus are on database and virtual storage capabilities as this is seen as an area in which it makes a lot of sense to move to 64-bit for Visual Studio 2005 can install and run on a 64-bit computer This IDE has both 32-bit and 64-bit compilers on it One final caveat is that the 64-bit NET Framework is meant only for Windows Server 2003 SP1 or better as well as other 64-bit Microsoft operating systems that might come our way When you build your applications in Visual Studio 2005, you can change the build properties of your application so that it compiles specifically for 64-bit computers To find this setting, you will need to pull up your application's properties and click on the Build tab from within the Properties page On the Build page, click on the Advanced button and this will pull up the Advanced Compiler Setting dialog From this dialog, you can change the target CPU from the bottom of the dialog From here, you can establish your application to be built for either an Intel 64-bit computer or an AMD 64-bit computer This is shown here in Figure I-1 Figure I-1: Building your application for 64-bit Generics In order to make collections a more powerful feature and also increase their efficiency and usability, generics were introduced to the NET Framework 2.0 This introduction to the underlying framework means that languages such as C# and Visual Basic 2005 can now build applications that use generic types The idea of generics is nothing new They look similar to C++ templates but are a bit different You can also find generics in other languages, such as Java Their introduction into the NET Framework 2.0 languages is a huge benefit for the user Generics enable you to make a generic collection that is still strongly typed — providing fewer chances for errors (because they occur at runtime), increasing performance, and giving you Intellisense features when you are working with the collections To utilize generics in your code, you will need to make reference to the System.Collections.Generic namespace This will give you access to generic versions of the Stack, Dictionary, SortedDictionary, List and Queue classes The following demonstrates the use of a generic version of the Stack class: void Page_Load(object sender, EventArgs e) { System.Collections.Generic.Stack myStack = New System.Collections.Generic.Stack(); myStack.Push("St Louis Rams"); myStack.Push("Indianapolis Colts"); myStack.Push("Minnesota Vikings"); Array myArray; myArray = myStack.ToArray(); foreach(string item in myArray) { Label1.Text += item + ""; } } In the above example, the Stack class is explicitly cast to be of type string Here, you specify the collection type with the use of brackets This example, casts the Stack class to type string using Stack If you wanted to cast it to something other than a Stack class of type string (for instance, int), then you would specify Stack Because the collection of items in the Stack class is cast to a specific type immediately as the Stack class is created, the Stack class no longer casts everything to type object and then later (in the foreach loop) to type string This process is called boxing, and it is expensive Because this code is specifying the types up front, the performance is increased for working with the collection In addition to just working with various collection types, you can also use generics with classes, delegates, methods and more Chapter 10 of this book covers generics in detail Anonymous methods Anonymous methods enable you to put programming steps within a delegate that you can then later execute instead of creating an entirely new method For instance, if you were not using anonymous methods, you would use delegates in a manner similar to the following: public partial class Default_aspx { void Page_Load(object sender, EventArgs e) { this.Button1.Click += ButtonWork; } void ButtonWork(object sender, EventArgs e) { Label1.Text = "You clicked the button!"; } } But using anonymous methods, you can now put these actions directly in the delegate as shown here in the following example: public partial class Default_aspx { void Page_Load(object sender, EventArgs e) { this.Button1.Click += delegate(object myDelSender, EventArgs myDelEventArgs) { Label1.Text = "You clicked the button!"; }; } } When using anonymous methods, there is no need to create a separate method Instead you place the necessary code directly after the delegate declaration The statements and steps to be executed by the delegate are placed between curly braces and closed with a semicolon Nullable types Due to the fact that generics has been introduced into the underlying NET Framework 2.0, it is now possible to create nullable value types — using System.Nullable This is ideal for situations such as creating sets of nullable items of type int Before this, it was always difficult to create an int with a null value from the get-go or to later assign null values to an int To create a nullable type of type int, you would use the following syntax: System.Nullable x = new System.Nullable; There is a new type modifier that you can also use to create a type as nullable This is shown in the following example: int? salary = 800000 This ability to create nullable types is not a C#-only item as this ability was built into NET Framework itself and, as stated, is there due to the existence of the new generics feature in NET For this reason, you will also find nullable types in Visual Basic 2005 as well Iterators Iterators enable you to use foreach loops on your own custom types To accomplish this, you need to have your class implement the IEnumerable interface as shown here: using System; using Systm.Collections; public class myList { internal object[] elements; internal int count; public IEnumerator GetEnumerator() { yield return "St Louis Rams"; yield return "Indianapolis Colts"; yield return "Minnesota Vikiings"; } } In order to use the IEnumerator interface, you will need to make a reference to the System.Collections namespace With this all in place, you can then iterate through the custom class as shown here: void Page_Load(object sender, EventArgs e) { myList IteratorList = new myList(); foreach(string item in IteratorList) { Response.Write(item.ToString() + ""); } } Partial Classes Partial classes are a new feature to the NET Framework 2.0 and again C# takes advantage of this addition Partial classes allow you to divide up a single class into multiple class files, which are later combined into a single class when compiled To create a partial class, you simply need to use the partial keyword for any classes that are to be joined together with a different class The partial keyword precedes the class keyword for the classes that are to be combined with the original class For instance, you might have a simple class called Calculator as shown here: public class Calculator { public int Add(int a, int b) { return a + b; } } From here, you can create a second class that attaches itself to this first class as shown here in the following example: public partial class Calculator { public int Subtract(int a, int b) { return a - b; } } When compiled, these classes will be brought together into a single Calculator class instance as if they were built together to begin with Next Page Next Page Where C# Fits In In one sense, C# can be seen as being the same thing to programming languages as NET is to the Windows environment Just as Microsoft has been adding more and more features to Windows and the Windows API over the past decade, Visual Basic 2005 and C++ have undergone expansion Although Visual Basic and C++ have ended up as hugely powerful languages as a result of this, both languages also suffer from problems due to the legacies of how they have evolved In the case of Visual Basic and earlier versions, the main strength of the language was the fact that it was simple to understand and didn't make many programming tasks easy, largely hiding the details of the Windows API and the COM component infrastructure from the developer The downside to this was that Visual Basic was never truly object-oriented, so that large applications quickly became disorganized and hard to maintain As well, because Visual Basic's syntax was inherited from early versions of BASIC(which, in turn, was designed to be intuitively simple for beginning programmers to understand, rather than to write large commercial applications), it didn't really lend itself to well-structured or object-oriented programs C++, on the other hand, has its roots in the ANSI C++ language definition It isn't completely ANSI- compliant for the simple reason that Microsoft first wrote its C++ compiler before the ANSI definition had become official, but it comes close Unfortunately, this has led to two problems First, ANSI C++ has its roots in a decade-old state of technology, and this shows up in a lack of support for modern concepts (such as Unicode strings and generating XML documentation), and for some archaic syntax structures designed for the compilers of yesteryear (such as the separation of declaration from definition of member functions) Second, Microsoft has been simultaneously trying to evolve C++ into a language that is designed for high-performance tasks on Windows, and in order to achieve that they've been forced to add a huge number of Microsoft-specific keywords as well as various libraries to the language The result is that on Windows, the language has become a complete mess Just ask C++ developers how many definitions for a string they can think of: char*, LPTSTR, string, CString (MFC version), CString (WTL version), wchar_t*, OLECHAR*, and so on Now enter NET — a completely new environment that is going to involve new extensions to both languages Microsoft has gotten around this by adding yet more Microsoft-specific keywords to C++, and by completely revamping Visual Basic into Visual Basic NET into Visual Basic 2005, a language that retains some of the basic VB syntax but that is so different in design that we can consider it to be, for all practical purposes, a new language It's in this context that Microsoft has decided to give developers an alternative — a language designed specifically for NET, and designed with a clean slate Visual C# 2005 is the result Officially, Microsoft describes C# as a "simple, modern, object-oriented, and type-safe programming language derived from C and C++." Most independent observers would probably change that to "derived from C, C++, and Java." Such descriptions are technically accurate but little to convey the beauty or elegance of the language Syntactically, C# is very similar to both C++ and Java, to such an extent that many keywords are the same, and C# also shares the same block structure with braces ({}) to mark blocks of code, and semicolons to separate statements The first impression of a piece of C# code is that it looks quite like C++ or Java code Beyond that initial similarity, however, C# is a lot easier to learn than C++, and of comparable difficulty to Java Its design is more in tune with modern developer tools than both of those other languages, and it has been designed to give us, simultaneously, the ease of use of Visual Basic, and the high- performance, low-level memory access of C++ if required Some of the features of C# are: Full support for classes and object-oriented programming, including both interface and implementation inheritance, virtual functions, and operator overloading A consistent and well-defined set of basic types Built-in support for automatic generation of XML documentation Automatic cleanup of dynamically allocated memory The facility to mark classes or methods with user-defined attributes This can be useful for documentation and can have some effects on compilation (for example, marking methods to be compiled only in debug builds) Full access to the NET base class library, as well as easy access to the Windows API (if you really need it, which won't be all that often) Pointers and direct memory access are available if required, but the language has been designed in such a way that you can work without them in almost all cases Support for properties and events in the style of Visual Basic Just by changing the compiler options, you can compile either to an executable or to a library of NET components that can be called up by other code in the same way as ActiveX controls (COM components) C# can be used to write ASP.NET dynamic Web pages and XML Web services Most of the above statements, it should be pointed out, also apply to Visual Basic 2005 and Managed C++ The fact that C# is designed from the start to work with NET, however, means that its support for the features of NET is both more complete, and offered within the context of a more suitable syntax than for those other languages While the C# language itself is very similar to Java, there are some improvements, in particular, Java is not designed to work with the NET environment Before we leave the subject, we should point out a couple of limitations of C# The one area the language is not designed for is time-critical or extremely high performance code — the kind where you really are worried about whether a loop takes 1,000 or 1,050 machine cycles to run through, and you need to clean up your resources the millisecond they are no longer needed C++ is likely to continue to reign supreme among low-level languages in this area C# lacks certain key facilities needed for extremely high performance apps, including the ability to specify inline functions and destructors that are guaranteed to run at particular points in the code However, the proportions of applications that fall into this category are very low Next Page Next Page What You Need To Write And Run C# Code The NET Framework will run on Windows 98, 2000, XP, and 2003 In order to write code using NET, you will need to install the NET SDK unless you are using Windows Server 2003, which comes with the NET Framework 1.0 and 1.1 already installed If you are going to work through the examples in this book though, you are going to want to install the NET Framework 2.0 — even if you are running Windows Server 2003 as the NET Framework 2.0 is not included on this server as a default Also, unless you are intending to write your C# code using a text editor or some other third party developer environment, you will almost certainly also want Visual Studio 2005 The full SDK isn't needed to run managed code, but the NET runtime is needed You may find you need to distribute the NET runtime with your code for the benefit of those clients who not have it already installed Next Page Next Page What This Book Covers In this book, we start by reviewing the overall architecture of NET in the next chapter in order to give us the background we need to be able to write managed code After that the book is divided into a number of sections that cover both the C# language and its application in a variety of areas Part I: The C# Language This section gives us a good grounding in the C# language itself This section doesn't presume knowledge of any particular language, although it does assume you are an experienced programmer We start by looking at C#'s basic syntax and data types, and then discuss the object-oriented features of C# before moving on to look at more advanced C# programming topics Part II: The NET Environment In this section, we look at the principles of programming in the NET environment In particular, we look at Visual Studio NET, security, threading deployment of NET applications, and how to generate your own libraries as assemblies Part III: Data Here we look at accessing databases with ADO.NET, and at interacting with directories and Active Directory We also extensively cover support in NET for XML and on the Windows operating system side, and the NET features of SQL Server 2005 Part IV: Windows Applications This section focuses on building classic Windows applications, which are called Windows Forms in.NET Windows Forms are the thick-client version of applications, and using NET to build these types of applications is a quick and easy way of accomplishing this task In addition to looking at Windows Forms, we will take a look at GDI+, which is the technology we will use for building applications that include advanced graphics Part V: Web Applications In this section, we cover writing components that will run on Web sites, serving up Web pages This covers the tremendous amount of new features that ASP.NET 2.0 provides Part VI: Communication This section is all about communication Here we cover Web services for platform-independent communication, NET Remoting for communication between NET clients and servers, Enterprise Services for the services in the background and DCOM communication With message queuing asynchronous, disconnected communication is shown The chapter "Future of Distributed Programming" prepares you for the future so you can make the correct communication choices for your current solutions Part VII: Interop Backward compatibility with COM is an important part of NET Too many COM components and applications have been developed This section shows how to use existing COM components with NET applications, and the other way around, how to use NET components within COM applications Part VIII: Windows Base Services This section, the concluding part of the main body of the book, covers accessing the file and registry, accessing the Internet through your applications, and working with Windows Services Part IX: Appendices (Web Site Only) This section includes several appendices detailing the principles of object-oriented programming as well as programming language-specific information about C# These appendices are available as PDFs on the Web site accompanying this book (http://www.wrox.com) Next Page Next Page Index W WaitCallback delegate, 366 #warning preprocessor directive, 72 WCF (Windows Communication Foundation) architecture, 1135 ASP.NET and, 1146 binding, 1141–1143 client applications, 1144 contracts, defined, 1137 data contract, 1137, 1138 described, 1125 Enterprise Services and, 1146–1147 features, 1134–1135 hosting, 1143–1144 layers of applications, 1135, 1136 message contract, 1137, 1139 Message Queuing and, 1147 NET Remoting and, 1145–1146 overview, 1134–1136 preparing for, 1145–1147 programming with, 1137–1144 service contract, 1137–1138 service implementation, 1139–1141 ways of sending messages, 1135 Web services contract, 1137 Web Forms See also ASP.NET; PCSDemoSite application (ASP.NET) ADO.NET and data binding for, 926–939 application configuration, 939–941 authentication using Security Wizard, 964–969 creating files with text editor, 905 creating in Visual Studio 2005, 906–908 creating with C#, 23 defined, 23 design considerations, 905–908 IDEs for, 905 Label control, 920 login system implementation, 969–970 tag, 908 PCSWebApp1 example, 906–908, 909 process after user requests, 909 restricting directory access, 971–973 security, 963–973 server control example, 920–925 state management in ASP.NET and, 905 Web server controls for, 23 Web server, client deployment from, 566–567 Web server controls (ASP.NET) See also event-booking application adding to PCSWebApp1 example, 911–913 binding to the database, 927–928 Crystal Reports controls, 914 data controls, 917–918 defined, 23, 910 login controls, 970–971 navigation controls, 960–963 runat="server" attribute, 910 standard controls, 914–917 validation controls, 918–920 WebParts controls, 920 Web Service Description Language See WSDL Web services See also Web services specifications adding a method accessible through, 988 consuming, 990–993 CookieContainer class with, 1004–1005 creating client for, 991–992 declaring custom SOAP header, 1002 defined, 983 event-booking application, 993–1001 exchanging data using SOAP headers, 1001–1007 exposing, 987–990 with NET Remoting, 1010 proxy class for, 990–992 SOAP for, 983, 984–985 types available for, 990 viewing WSDL for, 990 WCF contract for, 1137 WSDL for, 983, 985–987 WSDL.exe tool, 991 Web services specifications current issues, 1126–1127 performance and, 1133–1134 for transactions, 1131–1133 WS-Addressing, 1134 WS-AtomicTransactions, 1131 WS-BusinessActivity, 1131–1133 WS-Coordination, 1131 WS-Federation, 1127 WS-ReliableMessaging, 1129–1131 WS-SecureConversation, 1128–1129 WS-Security, 1128 WebBrowser control (Windows Forms) displaying the code of a requested page, 1256–1257 giving applications IE-type features, 1248–1253 printing using, 1255–1256 showing documents using, 1254–1255 for simple Web browsing from applications, 1246–1247 starting an Internet Explorer process programmatically, 1245–1246 WebClient class BasicWebClient example, 1240–1241 DownloadFile() method, 1240 OpenRead() method, 1240–1241 OpenWrite() method, 1241 overview, 1240 UploadData() method, 1242 UploadFile() method, 1242 web.config file ASP.NET application configuration, 940 for event-booking application, 993 element, 544 hosting NET Remoting servers in ASP.NET and, 1050–1051 WebParts Web server controls (ASP.NET), 920 WebRequest class asynchronous page requests, 1244–1245 authentication, 1244 BasicWebClient example, 1242–1243 class hierarchy, 1257–1258 HTTP header information support, 1243–1244 WebClient class versus, 1242 WebResponse class BasicWebClient example, 1242–1243 class hierarchy, 1257–1258 HTTP header information support, 1243–1244 WebClient class versus, 1242 WelcomeMessage() method, 535, 536, 541–542 Wellknown_Client.config file (.NET Remoting), 1043 Wellknown_Server.config file (.NET Remoting), 1042–1043 WhatsNewAttributes example LookUpWhatsNew assembly, 310, 321–324 overview, 310–311 VectorClass assembly, 310, 312–313 WhatsNewAttributes library assembly, 310, 311–312 WhatsNewChecker class, 321–322 while statements overview, 53 scope of local variables declared in, 36 in SimpleExceptions class, 334 Wiley Publishing, Inc Beginning XML, 659 Professional ASP.NET 1.1, 910, 940 Windows Controls, 24 Windows Forms See also events; graphics; specific classes, controls, and components ActiveX controls in, 1168–1171 appearance properties for controls, 760 application for ActiveX controls, 1169–1170 Button control, 762–763, 1249–1253 CheckBox control, 764 CheckedListBox control, 765 class hierarchy, 757–758 ComboBox control, 765, 767 ContextMenuStrip class, 779 Control class, 759–762 controlling appearance of forms, 784–786 creating an application, 752–757 custom controls, 787–799 DateTimePicker control, 765 disposing of forms, 755 ErrorProvider component, 767–769 FlowLayoutPanel control, 774–775 focus, gaining and losing for controls, 761 FolderTree custom control, 789–794 Form class, 752, 780–786 Form, defined, 780 globalization demo application, 520–524 grouping controls on tab pages, 776 Height property, 92–93 HelpProvider component, 769 ImageList component, 769 Label control, 769–770 LinkLabel control, 1248 ListBox control, 765–767 ListView control, 770–772 Localizable property, 536, 537 localization application, 520–524 MaskedTextBox control, 773, 774 MDI (Multiple Document Interface), 786–787 MenuStrip control, 779 namespaces for, 751 overview, 24 Panel control, 774 PictureBox control, 772 ProgressBar control, 772 RadioButton control, 764 reading drive information, 1220–1222 reading from files, 1202–1204 RichTextBox control, 773–774 running controls in Internet Explorer, 1183 SDI (Single Document Interface), 781 setting colors for forms, 785 shape-drawing application, 844–847 showing forms in taskbar, 782 size and location properties for controls, 759–760 SplitContainer control, 775 standard controls and components, 762–780 system menu for forms, 784–785 TabControl control, 776 TableLayoutPanel control, 774, 775 TabPages control, 776 TextBox control, 773, 1246–1247 ToolStrip control, 776–779 ToolStripContainer control, 780 ToolStripControlHost control, 777–779 ToolStripDropDownItem control, 777 ToolStripManager class, 780 ToolStripMenuItem class, 779–780 TreeView control, custom control based on, 788–794 user interaction, 760–761, 782–784 UserSearch Active Directory application, 740–745 visibility of forms, 781, 782 visual styles for forms, 785–786 WebBrowser control, 1245–1247, 1248–1257 Windows functionality and, 761–762 writing to files, 1204–1205 Windows Installer projects ClickOnce compared to Windows Installer, 567–568 creating installers, 557–567 for Enterprise Services, 1074–1075 installing client from Web server, 566–567 No Touch Deployment (NTD), 566–567 options for deployment, 552 project types available, 556 simple client application, deployment project as separate solution, 558–562 simple client application, deployment project in same solution, 563–564 simple Web application, 564–565 Windows Installer overview, 556–557 for Windows Services, 1287–1292 Windows Resource Localization Editor (winres.exe), 543 Windows Services See also quote server application architecture, 1272–1275 class library using sockets, 1276–1279 creating as service, 1275–1292 defined, 1271 event logging, 1302–1308 example services, 1272 handler methods, 1274 installing, 1287–1292 interactive services, 1302 monitoring and controlling services, 1292–1301 namespace for, 1275 net.exe utility, 1293–1294 overview, 24 performance monitoring, 1308–1313 power events and, 1314 project wizard for, 1281–1283 QuoteService example, 1281–1286 sc.exe utility, 1294–1295 service configuration program, 1275 Service Control Manager (SCM), 1273, 1274 service control program, 1275 service program, 1273–1274 service start, 1285 ServiceBase class, 1283–1284 ServiceController class, 1295–1301 service-main function, 1273–1274 Services administration tool, 1272 Services MMC snap-in, 1293 TcpClient example, 1279–1281 threading and, 1287 troubleshooting, 1301–1313 viewing all services on a system, 1272 Visual Studio Server Explorer, 1295 Windows.Forms namespace, 188 winres.exe (Windows Resource Localization Editor), 543 worker threads, 352 world coordinates, 863 WorldCoordinatesToLineIndex() method, 889 WorldYCoordinateToLineIndex() method, 889 WriteAttributeInfo() method, 323 WriteMatches() method, 240 write-only properties, avoiding, 81, 94 WriteXml() method (DataSet class), 624–625, 690–691 writing to files binary files, 1208–1213 overview, 1201 text files, 1213–1219 Windows Forms for, 1204–1205 WROX Web site, 895, 920, 1151 WS-Addressing specification, 1134 WS-AtomicTransactions specification, 1131 WS-BusinessActivity specification, 1131–1133 WS-Coordination specification, 1131 WSDL (Web Service Description Language) described, 983 overview, 985–987 type-definition section, 985–986 viewing for Web services, 990 as WCF contract, 1137 as XML-compliant syntax, 985 WSDL.exe tool, 991 WS-Federation specification, 1127 WS-ReliableMessaging specification, 1129–1131 WS-SecureConversation specification, 1128–1129 WS-Security specification, 1128 Next Page Next Page Index X xcopy deployment, 552, 554–555 XML See also XML data type (SQL Server) ASP.NET server control syntax based on, 910 comments, 68–70 converting ADO.NET relational data to, 694–696 converting ADO.NET single table data to, 689–694 converting to ADO.NET data, 696–699 DiffGram documents, 699–701 further information, 659 namespace for, 659, 660–661 Office applications supporting, 651 populating a DataSet from, 620 reading streamed XML, 664–670 relational data and, 651 resX files for resources, 526, 527–528 serializing objects in, 701–711 standards supported in NET, 660 transforming into HTML, 684–686 using MSXML 4.0 in NET, 661–663 using the DOM in NET, 672–678 writing output with DataSet, 623–625, 690–691 writing streamed XML, 670–672 WSDL compliance with, 985 XmlReader with ADO.NET, 593–594 XPathNavigators, 678–689 XML Data Modification Language (XML DML), 654–655 XML data type (SQL Server) introduction of, 650 Office applications supporting XML, 651 querying data, 653–654 relational data and, 651 strongly typed XML, 656–657 tables with XML data, 651–653 XML Data Modification Language (XML DML), 654–655 XML indexes, 655–656 XML DML (XML Data Modification Language), 654–655 XML schema definition (XSD) schemas See XSD schemas XML Web services, 23 XmlAttributeOverrides class, 708–710 XmlAttributes class, 708–710 XmlCharacterData class, 672, 674 XmlDataDocument class, 692–693 XmlDocument class converting ADO.NET data to XML, 689–694 creating a document from scratch, 677–678 described, 661 DOM representation using, 673 inserting nodes, 675–678 using, 673–675 XmlElement class, 676 XmlLinkedNode class classes extending, 673 described, 672 inheritance diagram for, 674 XmlNode class classes based on, 672 described, 661, 672 inheritance diagram for, 674 XmlNodeReader class, 664 XmlReader class classes derived from, 664 Create method for, 665 described, 660 GetAttribute() method, 668 properties for controlling processing of nodes and values, 665 Read() method, 665 ReadElementString() method, 665–667 ReadStartElement() method, 665 ReadValueAs methods, 667 retrieving attribute data, 668 SAX versus, 664 simple example, 665 validating XML to an XSD schema, 668–670 XmlReaderSettings class, 665, 668, 670 XmlSerializer class, 703 XmlTextReader class described, 661, 664 EOF property, 666 XmlTextWriter class described, 661, 664 using, 670–671, 677 XmlValidatingReader class, 664 XmlWriter class classes derived from, 664 described, 660 using, 670–671 XmlWriterSettings class, 670, 671 XPathDocument class, 678 XPathException class, 679 XPathExpression class, 679, 682 XPathNavigator class described, 678 move methods, 679–680 select methods, 680 using, 681–683 XPathNavigators See also specific namespaces defined, 678 System.Xml.XPath namespace for, 678–684 System.Xml.Xsl namespace for, 684–689 XPathNodeIterator class described, 678 properties and methods, 680–681 using, 682, 683–684 xsd command converting XSD files into code, 613 output for Products schema, 613–618 switches, 613 XSD (XML schema definition) schemas See also xsd command adding elements, 829 building with Visual Studio NET, 827–832 DataColumn for, 831–832 DataRow for, 830–831 DataTable for, 829–830 EventArgs for, 832 generating from books.xml file, 668–669 overview, 612–613 Schema view versus XML view, 828 TestSchema.cs example, 828–832 validating XML to, 668–670 XmlReader class for validating, 669–670 xsd.exe tool, 702 Next Page Next Page Index Z zero impact installation of private assemblies, 18 Next Page List of Figures Introduction Figure I-1: Building your application for 64-bit Chapter 1: NET Architecture Figure 1-1: Figure 1-2: Figure 1-3: Figure 1-4: Chapter 5: Operators and Casts Figure 5-1: Chapter 7: Memory Management and Pointers Figure 7-1: Figure 7-2: Figure 7-3: Figure 7-4: Figure 7-5: Figure 7-6: Chapter 8: Strings and Regular Expressions Figure 8-1: Figure 8-2: Figure 8-3: Chapter 9: Collections Figure 9-1: Figure 9-2: Figure 9-3: Chapter 10: Generics Figure 10-1: Figure 10-2: Figure 10-3: Figure 10-4: Chapter 11: Reflection Figure 11-1: Figure 11-2: Chapter 12: Errors and Exceptions Figure 12-1: Chapter 13: Threading Figure 13-1: Chapter 14: Visual Studio 2005 Figure 14-1: Figure 14-2: Figure 14-3: Figure 14-4: Figure 14-5: Figure 14-6: Figure 14-7: Figure 14-8: Figure 14-9: Figure 14-10: Figure 14-11: Figure 14-12: Figure 14-13: Figure 14-14: Figure 14-15: Figure 14-16: Figure 14-17: Figure 14-18: Figure 14-19: Figure 14-20: Figure 14-21: Figure 14-22: Figure 14-23: Figure 14-24: Figure 14-25: Figure 14-26: Figure 14-27: Figure 14-28: Chapter 15: Assemblies Figure 15-1: Figure 15-2: Figure 15-3: Figure 15-4: Figure 15-5: Figure 15-6: Figure 15-7: Figure 15-8: Figure 15-9: Figure 15-10: Figure 15-11: Figure 15-12: Figure 15-13: Figure 15-14: Figure 15-15: Figure 15-16: Figure 15-17: Figure 15-18: Figure 15-19: Figure 15-20: Figure 15-21: Figure 15-22: Figure 15-23: Figure 15-24: Figure 15-25: Figure 15-26: Figure 15-27: Figure 15-28: Figure 15-29: Figure 15-30: Figure 15-31: Figure 15-32: Figure 15-33: Figure 15-34: Figure 15-35: Figure 15-36: Figure 15-37: Figure 15-38: Figure 15-39: Figure 15-40: Figure 15-41: Figure 15-42: Figure 15-43: Figure 15-44: Chapter 16: NET Security Figure 16-1: Figure 16-2: Figure 16-3: Figure 16-4: Figure 16-5: Figure 16-6: Figure 16-7: Figure 16-8: Figure 16-9: Figure 16-10: Figure 16-11: Figure 16-12: Figure 16-13: Figure 16-14: Figure 16-15: Figure 16-16: Chapter 17: Localization Figure 17-1: Figure 17-2: Figure 17-3: Figure 17-4: Figure 17-5: Figure 17-6: Figure 17-7: Figure 17-8: Figure 17-9: Figure 17-10: Figure 17-11: Figure 17-12: Figure 17-13: Figure 17-14: Figure 17-15: Figure 17-16: Figure 17-17: Figure 17-18: Figure 17-19: Figure 17-20: Figure 17-21: Figure 17-22: Chapter 18: Deployment Figure 18-1: Figure 18-2: Figure 18-3: Figure 18-4: Figure 18-5: Figure 18-6: Chapter 19: Data Access with NET Figure 19-1: Figure 19-2: Figure 19-3: Figure 19-4: Figure 19-5: Figure 19-6: Figure 19-7: Figure 19-8: Figure 19-9: Figure 19-10: Figure 19-11: Figure 19-12: Chapter 20: NET Programming with SQL Server 2005 Figure 20-1: Figure 20-2: Figure 20-3: Figure 20-4: Chapter 21: Manipulating XML Figure 21-1: Figure 21-2: Figure 21-3: Figure 21-4: Figure 21-5: Figure 21-6: Chapter 22: Working with Active Directory Figure 22-1: Figure 22-2: Figure 22-3: Figure 22-4: Figure 22-5: Figure 22-6: Figure 22-7: Figure 22-8: Figure 22-9: Figure 22-10: Figure 22-11: Figure 22-12: Figure 22-13: Figure 22-14: Figure 22-15: Figure 22-16: Figure 22-17: Chapter 23: Windows Forms Figure 23-1: Figure 23-2: Figure 23-3: Figure 23-4: Figure 23-5: Chapter 24: Viewing NET Data Figure 24-1: Figure 24-2: Figure 24-3: Figure 24-4: Figure 24-5: Figure 24-6: Figure 24-7: Figure 24-8: Figure 24-9: Figure 24-10: Figure 24-11: Figure 24-12: Figure 24-13: Figure 24-14: Figure 24-15: Figure 24-16: Figure 24-17: Figure 24-18: Figure 24-19: Figure 24-20: Figure 24-21: Figure 24-22: Figure 24-23: Figure 24-24: Figure 24-25: Figure 24-26: Figure 24-27: Figure 24-28: Figure 24-29: Chapter 25: Graphics with GDI+ Figure 25-1: Figure 25-2: Figure 25-3: Figure 25-4: Figure 25-5: Figure 25-6: Figure 25-7: Figure 25-8: Figure 25-9: Figure 25-10: Figure 25-11: Figure 25-12: Figure 25-13: Figure 25-14: Figure 25-15: Figure 25-16: Figure 25-17: Figure 25-18: Figure 25-19: Figure 25-20: Chapter 26: ASP.NET Pages Figure 26-1: Figure 26-2: Figure 26-3: Figure 26-4: Figure 26-5: Figure 26-6: Figure 26-7: Figure 26-8: Figure 26-9: Figure 26-10: Figure 26-11: Figure 26-12: Figure 26-13: Figure 26-14: Figure 26-15: Chapter 27: ASP.NET Development Figure 27-1: Figure 27-2: Figure 27-3: Figure 27-4: Figure 27-5: Figure 27-6: Figure 27-7: Figure 27-8: Figure 27-9: Figure 27-10: Figure 27-11: Figure 27-12: Figure 27-13: Figure 27-14: Figure 27-15: Figure 27-16: Figure 27-17: Chapter 28: Web Services Figure 28-1: Figure 28-2: Figure 28-3: Figure 28-4: Figure 28-5: Chapter 29: NET Remoting Figure 29-1: Figure 29-2: Figure 29-3: Figure 29-4: Figure 29-5: Figure 29-6: Figure 29-7: Figure 29-8: Figure 29-9: Figure 29-10: Figure 29-11: Figure 29-12: Figure 29-13: Figure 29-14: Figure 29-15: Figure 29-16: Figure 29-17: Chapter 30: Enterprise Services Figure 30-1: Figure 30-2: Figure 30-3: Figure 30-4: Figure 30-5: Figure 30-6: Figure 30-7: Figure 30-8: Figure 30-9: Chapter 31: Message Queuing Figure 31-1: Figure 31-2: Figure 31-3: Figure 31-4: Figure 31-5: Figure 31-6: Figure 31-7: Figure 31-8: Figure 31-9: Figure 31-10: Figure 31-11: Figure 31-12: Figure 31-13: Chapter 32: Future of Distributed Programming Figure 32-1: Figure 32-2: Figure 32-3: Figure 32-4: Figure 32-5: Figure 32-6: Figure 32-7: Chapter 33: COM Interoperability Figure 33-1: Figure 33-2: Figure 33-3: Figure 33-4: Figure 33-5: Figure 33-6: Figure 33-7: Figure 33-8: Figure 33-9: Figure 33-10: Figure 33-11: Figure 33-12: Figure 33-13: Chapter 34: Manipulating Files and the Registry Figure 34-1: Figure 34-2: Figure 34-3: Figure 34-4: Figure 34-5: Figure 34-6: Figure 34-7: Figure 34-8: Figure 34-9: Figure 34-10: Figure 34-11: Figure 34-12: Figure 34-13: Figure 34-14: Figure 34-15: Figure 34-16: Figure 34-17: Figure 34-18: Figure 34-19: Figure 34-20: Chapter 35: Accessing the Internet Figure 35-1: Figure 35-2: Figure 35-3: Figure 35-4: Figure 35-5: Figure 35-6: Figure 35-7: Figure 35-8: Figure 35-9: Figure 35-10: Figure 35-11: Figure 35-12: Figure 35-13: Figure 35-14: Chapter 36: Windows Services Figure 36-1: Figure 36-2: Figure 36-3: Figure 36-4: Figure 36-5: Figure 36-6: Figure 36-7: Figure 36-8: Figure 36-9: Figure 36-10: Figure 36-11: Figure 36-12: Figure 36-13: Figure 36-14: Figure 36-15: Figure 36-16: Figure 36-17: Figure 36-18: Figure 36-19: Figure 36-20: Figure 36-21: Figure 36-22: Figure 36-23: Figure 36-24: Figure 36-25: Figure 36-26: Figure 36-27: Appendix A: Principles of Object- Oriented Programming Figure A-1: Figure A-2: Figure A-3: Figure A-4: Figure A-5: Appendix B: C# for Visual Basic Developers Figure B-1: Figure B-2: Figure B-3: Figure B-4: ... then you would specify Stack Because the collection of items in the Stack class is cast to a specific type immediately as the Stack class is created, the Stack class no longer casts everything... class called Calculator as shown here: public class Calculator { public int Add(int a, int b) { return a + b; } } From here, you can create a second class that attaches itself to this first class... to compile Visual Basic 2005 to native executable code Visual Basic 2005 compiles only to IL, just as C# does If you need to continue coding in Visual Basic 6, you can so, but the executable code

Ngày đăng: 26/03/2019, 16:02