
- •maranGraphics
- •CREDITS
- •ACKNOWLEDGMENTS
- •ABOUT THE AUTHORS
- •AUTHORS’ ACKNOWLEDGMENTS
- •TABLE OF CONTENTS
- •HOW TO USE THIS BOOK
- •INTRODUCTION TO C#
- •START VISUAL STUDIO .NET
- •OPEN A NEW C# PROJECT
- •OPEN A C# WEB PROJECT
- •SET JSCRIPT .NET AS THE DEFAULT SCRIPT LANGUAGE
- •EXPLORE THE CLASS VIEW WINDOW
- •VIEW THE CONTENTS WINDOW
- •GET HELP USING THE INDEX WINDOW
- •SEARCH FOR HELP
- •ADD COMPONENTS FROM THE TOOLBOX
- •ADD A TASK TO THE TASK LIST
- •CHANGE FORM PROPERTIES IN THE PROPERTIES WINDOW
- •ADD A CUSTOM TOOLBAR
- •DELETE A TOOLBAR
- •CHANGE THE VISUAL STUDIO ENVIRONMENT
- •MANAGE OPEN WINDOWS
- •OPEN A PROJECT
- •VIEW THE MAIN METHOD
- •COMBINE PROGRAM TYPES
- •ADD REFERENCE TYPES
- •ADD OPERATORS
- •INSERT ATTRIBUTES
- •ENTER CLASSES
- •ADD COMMENTS TO CODE
- •WRITE YOUR FIRST PROGRAM
- •ENTER XML DOCUMENTATION
- •ACCESS DOCUMENTATION
- •LOG A BUG REPORT
- •VIEW INFORMATION ABOUT C# BUILDING BLOCKS
- •PROGRAM CLASSES
- •ADD A CLASS
- •EMPLOY CLASS INHERITANCE
- •PROGRAM INSTANCE CONSTRUCTORS
- •INSERT DESTRUCTORS
- •PROGRAM STRUCTS
- •DISPLAY HEAP AND STACK INFORMATION
- •FIND TYPE INFORMATION
- •PROGRAM CONSTANT EXPRESSIONS
- •SPECIFY VALUE TYPES
- •PROGRAM NUMERIC TYPES
- •PROGRAM THE BOOLEAN TYPE
- •DECLARE REFERENCE TYPES
- •ENTER REFERENCE TYPE DECLARATIONS
- •CONVERT VALUE TYPES TO REFERENCE TYPES
- •PROGRAM POINTER TYPES
- •INSERT THE VOID TYPE
- •ADD INTERFACE PROPERTIES
- •ADD AN INTERFACE INDEX
- •VIEW INFORMATION ABOUT METHODS
- •ADD A METHOD
- •ADD STATIC METHODS
- •INCLUDE NON-STATIC METHODS
- •ENTER DELEGATES
- •PROGRAM EVENTS
- •ADD AN EVENT-HANDLING METHOD
- •VIEW INFORMATION ABOUT ARRAYS
- •ENTER SINGLE-DIMENSIONAL ARRAYS
- •ADD MULTIDIMENSIONAL ARRAYS
- •PROGRAM ARRAY-OF-ARRAYS
- •ITERATE THROUGH ARRAY ELEMENTS
- •SORT ARRAYS
- •SEARCH ARRAYS
- •IMPLEMENT A COLLECTIONS CLASS
- •PROGRAM STRUCTS
- •ADD AN INDEXER
- •INCLUDE ENUMERATIONS
- •CREATE STRING LITERALS AND VARIABLES
- •ASSIGN VALUES TO STRINGS
- •CONCATENATE STRINGS
- •COMPARE STRINGS
- •SEARCH FOR SUBSTRINGS
- •REPLACE CHARACTERS
- •EXTRACT SUBSTRINGS
- •CHANGE THE CHARACTER CASE
- •TRIM SPACES
- •REMOVE CHARACTERS
- •SPLIT A STRING
- •JOIN STRINGS
- •PAD STRINGS
- •VIEW INFORMATION ABOUT PROPERTIES
- •COMPARE PROPERTIES AND INDEXERS
- •PROGRAM PROPERTY ACCESSORS
- •DECLARE ABSTRACT PROPERTIES
- •INCLUDE PROPERTIES ON INTERFACES
- •VIEW INFORMATION ABOUT WINDOWS FORMS
- •ADD A WINDOWS FORM IN THE WINDOWS FORM DESIGNER
- •SET THE FORM TYPE
- •CHOOSE THE STARTUP WINDOWS FORM
- •CREATE A MODAL FORM
- •LAYOUT A FORM
- •SET A FORM LOCATION
- •CHANGE FORM PROPERTIES
- •CREATE A TRANSPARENT FORM
- •AN INTRODUCTION TO WEB FORMS AND CONTROLS
- •CREATE AN ASP.NET WEB SITE
- •CREATE A WEB FORM
- •ADD SERVER CONTROLS TO A WEB FORM
- •READ AND CHANGE PROPERTIES FROM OBJECTS ON A WEB FORM
- •USING SERVER-SIDE COMPONENTS ON WEB FORMS
- •INTRODUCING DATA ACCESS WITH ADO.NET
- •DISPLAY DATA WITH THE DATAGRID CONTROL
- •CONFIGURE THE DATAGRID CONTROL
- •INSERT DATA INTO A SQL DATABASE
- •UPDATE DATA FROM A SQL DATABASE
- •DELETE DATA FROM A SQL DATABASE
- •EXECUTE A STORED PROCEDURE IN A SQL DATABASE
- •READ XML FROM A FILE
- •SAVE XML TO A FILE
- •QUERY XML WITH XPATH
- •APPLY XSL TO XML
- •INTRODUCTION TO DISTRIBUTED APPLICATIONS
- •CREATE AN APPLICATION WITH PRIVATE ASSEMBLIES
- •CREATE AN APPLICATION WITH SHARED ASSEMBLIES
- •VERSION A SHARED ASSEMBLY
- •CONFIGURE A CLIENT FOR A VERSIONED ASSEMBLY
- •CREATE A WEB SERVICE
- •USING A WEB SERVICE
- •INTRODUCTION TO EXCEPTION HANDLING
- •THROWING AN EXCEPTION
- •HANDLING EXCEPTIONS WITH THE CATCH BLOCK
- •USING THE FINALLY BLOCK
- •WRITE ERRORS TO THE APPLICATION LOG
- •BASIC EXAMPLES
- •WHAT’S ON THE CD-ROM
- •USING THE E-VERSION OF THIS BOOK
- •INDEX
- •Symbols & Numbers

C#
ENTER XML DOCUMENTATION
After you document your code and compile it, C# automatically changes that code into Extensible Markup Language, XML, format. XML comments
let you pass those comments easily if you want to share them with others, such as on a corporate Intranet, for feedback.
XML is a cross between HTML, Hypertext Markup Language, and the more powerful SGML, Standard Generalized Markup Language. XML contains greater flexibility than HTML but XML is not as hard to learn and use as SGML is.
XML is the default documentation language for Visual Studio .NET. You can compile the XML comments in your
program into an XML file that can then be shared on the Internet or on your company intranet using your Internet browser, provided that your browser is XML-capable.
However, the job of processing the XML file so that it can create XML documentation is up to your site Webmaster.
XML documentation in your program starts with three slash marks, ///. Visual C# also includes 14 built-in XML tags for user documentation such as the <summary> tag. Visual C# processes the XML tags on types and type members such as classes, and that is why you will see some XML documentation when you view the code in a Visual C# project, other than an empty project, that is.
ENTER XML DOCUMENTATION
Console
Applicatio
Click New Project in the
page.
■ The New Project window appears.
‹ Click the Console Application icon in the Templates pane.
› Type a name for your file.
ˇ Click OK.

WORKING WITH VISUAL C# BASICS 3
You can also use the slash-and-asterisk combination — /* and */ — just as you do with Java and C++ if you prefer doing so.
TYPE THIS:
using System;
/* This is a comment about the following class. */
public class Class1;RESULT:
As with Java and C++, remember that the asterisk always appears immediately before and after the comment text.
Á Replace the summary comments with your own text.
‡ Type three slashes (///) before the Main method in your text.
■ The summary XML tags and the ancillary param tag appear automatically.
° Add the <c> XML tag for denoting code.
■ The closing </c> code appears automatically.
· Type your comment text with your code text between the <c> and </c> codes.
‚ Save the program as the filename.
59

C#
ACCESS DOCUMENTATION
The MDE window gives you access to many different sources of help so you can get the answers you need quickly and get back to programming.
These sources include online text files that provide help and online resources from the Microsoft Web site. The online help files and Web pages appear directly within the MDE window so you do not have to close the MDE window and open a new one.
Visual Studio .NET installs online help as part of its installation process. You can access these files directly from the MDE window menu bar. Visual Studio .NET groups
these files by topic so you can find what you want easily. If you need more powerful search features, you can search by keywords and other criteria such as limiting results to Visual C# topics. When you view a help page, it appears in the parent window as another tab so you can switch between your help page and C# program.
When you view the online help features, those Web pages appear in the parent window as well. You can navigate these pages just as you would in a Web browser so you can find the information you want. The MDE window also includes a built-in online search feature so you can find what you need online more effectively.
ACCESS DOCUMENTATION
Note: If you have a dial-up Internet connection, your dial-up connection window will appear so you can dial your Internet service provider. If you cannot connect to the Internet, the parent window displays an action cancelled message stating that Internet Explorer was unable to connect.
Visual C#
■ The Headlines screen appears in the Start menu with the Features tab selected.
‹ Click to the right of the Filter field.
› Filter the headline articles to show Visual C# articles only by clicking Visual C#.

WORKING WITH VISUAL C# BASICS 3
If you decide to view a Webcast in MSDN Online that requires Windows Media Player and you do not have the Player, you can download the Player from the Webcast’s opening HTML screen that contains an overview of the Webcast and links to download the Player.
You can send feedback directly from the MSDN Online site by clicking the Send Us Your Feedback link at the lower left-hand corner of the MSDN Online window. After you click the link, you can enter feedback on the MSDN articles or features or submit a bug report about the MSDN Web site, but not about Visual Studio
.NET.
You can search for specific articles within MSDN Online by entering a search phrase in the Enter Search Phrase text box in the upper–left of the MSDN Online window and then click the Search button. The results will then appear in the MSDN Online window. If you need to conduct a more refined search, you can click the Advanced link below the Search button.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ˇ Click the Technical |
■ The latest technical articles |
Á Click the Knowledge |
■ Knowledge Base articles |
|||||
Articles tab. |
about C# appear. |
Base tab. |
appear that contain the latest |
|||||
|
|
|
|
|
|
C# support issues. |
61