ebook img

C# Programming: From Problem Analysis to Program Design PDF

1033 Pages·2007·20.29 MB·English
Save to my drive
Quick download
Download
Most books are stored in the elastic cloud where traffic is expensive. For this reason, we have a limit on daily download.

Preview C# Programming: From Problem Analysis to Program Design

C6374_FM_CTP 7/11/07 4:29 PM Page i C# Programming: From Problem Analysis to Program Design, Second Edition Copyright 2008 Cengage Learning, Inc. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. C6374_FM_CTP 7/11/07 4:29 PM Page ii Copyright 2008 Cengage Learning, Inc. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. C6374_FM_CTP 7/11/07 4:29 PM Page iii C# Programming: From Problem Analysis to Program Design, Second Edition Barbara Doyle Australia • Canada • Mexico • Singapore • Spain • United Kingdom • United States Copyright 2008 Cengage Learning, Inc. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. C6374_FM_CTP 7/11/07 4:29 PM Page iv C# Programming: From Problem Analysis to Program Design, Second Edition by Barbara Doyle Senior Product Manager: Marketing Manager: Compositor: Alyssa Pratt Bryant Chrzan GEX Publishing Services Acquisitions Editor: Cover Designer: Senior Print Buyer: Amy Jollymore Lisa Kuhn Justin Palmeiro Content Product Manager: Editorial Assistant: Pam Elizian Patrick Frank COPYRIGHT © 2008 Course Technology, ALL RIGHTS RESERVED. No part of this Disclaimer a division of Thomson Learning, Inc. work covered by the copyright hereon Course Technology reserves the right Thomson Learning™ is a trademark may be reproduced or used in any to revise this publication and make used herein under license. form or by any means—graphic, elec- changes from time to time in its con- tronic, or mechanical, including photo- tent without notice. The programs in Printed in the United States of America copying, recording, taping, Web this book are for instructional purposes distribution, or information storage only. They have been tested with care 1 2 3 4 5 6 7 8 9 TC 11 10 09 08 07 and retrieval systems—without the but are not guaranteed for any partic- written permission of the publisher. ular intent beyond educational pur- For more information, contact Course poses. The author and the publisher do Technology, 25 Thomson Place, Boston, For permission to use material from not offer any warranties or representa- Massachusetts, 02210. this text or product, contact us by tions, nor do they accept any liabilities Or find us on the World Wide Web at: Tel (800) 730-2214 with respect to the programs. www.course.com Fax(800) 730-2215 www.thomsonrights.com 10-digit ISBN: 1-4239-0146-0 13-digit ISBN: 978-1-4239-0146-4 Copyright 2008 Cengage Learning, Inc. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. C6374_FM_CTP 7/11/07 4:29 PM Page v Brief Contents PREFACE xix 1.Introduction to Computing and Programming 1 2.Your First C# Program 41 3.Data Types and Expressions 83 4.Methods and Behaviors 135 5.Making Decisions 209 6.Repeating Instructions 265 7.Arrays and Collections 329 8.Introduction to Windows Programming 401 9.Programming Based on Events 479 10. Advanced Object-Oriented Programming Features 577 11. Debugging and Handling Exceptions 649 12. Working with Files 705 13. Database Access using ADO.NET 757 14. Web-Based Applications 835 Copyright 2008 Cengage Learning, Inc. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. C6374_FM_CTP 7/11/07 4:29 PM Page vi vi C# Programming: From Problem Analysis to Program Design APPENDIX A Compiling and Running an Application from the Command Line 925 APPENDIX B Visual Studio Configuration 935 APPENDIX C Code Editor Tools 945 APPENDIX D Character Sets 957 APPENDIX E Operator Precedence 959 APPENDIX F C# Keywords 960 APPENDIX G Coding Standards 961 GLOSSARY 965 INDEX 979 Copyright 2008 Cengage Learning, Inc. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. C6374_FM_CTP 7/11/07 4:29 PM Page vii Table of Contents PREFACE xix 1.Introduction to Computing and Programming 1 History of Computers 2 Physical Components of a Computer System 5 Hardware 5 Processor 6 Storage 7 Input and Output Devices 9 Data Representation 9 Bits 9 Bytes 9 Binary Numbering System 10 Character Sets 12 Kilobyte,Megabyte,Gigabyte,Terabyte,Petabyte… 13 System and Application Software 13 System Software 14 Application Software 15 Software Development Process 15 Steps in the Program Development Process 16 Programming Methodologies 23 Structured Procedural Programming 23 Object-Oriented Programming 25 Evolution of C# and .NET 28 Programming Languages 28 .NET 29 Why C#? 32 Resources 33 Quick Review 34 Exercises 36 Copyright 2008 Cengage Learning, Inc. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. C6374_FM_CTP 7/11/07 4:29 PM Page viii viii C# Programming: From Problem Analysis to Program Design 2.Your First C# Program 41 Types of Applications Developed with C# 42 Web Applications 42 Windows Applications 43 Console Applications 44 Exploring the First C# Program 45 Elements of a C# Program 46 Comments 46 Using Directive 47 Namespace 49 Class Definition 50 Main( ) Method 50 Method Body—Statements 51 Installing the .NET Framework 55 Creating a Place to Store Your Work 56 Typing Your Program Statements 57 Compiling,Building,and Running an Application 58 Compilation and Execution Process 58 Compiling the Source Code Using Visual Studio IDE 59 Debugging an Application 66 Syntax Errors 66 Run-time Errors 68 Creating an Application 68 Programming Example:ProgrammingMessage 69 Resources 74 Quick Review 75 Exercises 76 Programming Exercises 80 3.Data Types and Expressions 83 Memory Locations for Data 84 Identifiers 84 Variables 87 Literal Values 88 Types,Classes,and Objects 89 Copyright 2008 Cengage Learning, Inc. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. C6374_FM_CTP 7/11/07 4:29 PM Page ix Table of Contents ix Types 89 Classes 89 Objects 90 Predefined Data Types 91 Value Types 92 Integral Data Types 93 Floating-Point Types 95 Decimal Types 97 Boolean Variables 98 Declaring Strings 98 Making Data Constant 99 Assignment Statements 100 Basic Arithmetic Operations 103 Increment and Decrement Operations 105 Compound Operations 108 Order of Operations 110 Mixed Expressions 112 Casts 114 Formatting Output 114 Programming Example:CarpetCalculator 118 Resources 126 Quick Review 126 Exercises 127 Programming Exercises 132 4.Methods and Behaviors 135 Anatomy of a Method 136 Modifiers 138 Return Type 141 Method Name 142 Parameters 142 Method Body 143 Calling Class Methods 144 Predefined Methods 146 Writing Your Own Class Methods 159 Copyright 2008 Cengage Learning, Inc. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part.

See more

The list of books you might like

Most books are stored in the elastic cloud where traffic is expensive. For this reason, we have a limit on daily download.