100% found this document useful (4 votes)
79 views84 pages

Instant Ebooks Textbook C Programming From Problem Analysis To Program Design 4th Edition Barbara Doyle Download All Chapters

ebook

Uploaded by

brozikalake
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
100% found this document useful (4 votes)
79 views84 pages

Instant Ebooks Textbook C Programming From Problem Analysis To Program Design 4th Edition Barbara Doyle Download All Chapters

ebook

Uploaded by

brozikalake
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 84

Full download ebook at ebookgate.

com

C Programming From Problem Analysis to


Program Design 4th Edition Barbara Doyle

https://ebookgate.com/product/c-programming-from-
problem-analysis-to-program-design-4th-edition-
barbara-doyle/

Download more ebook from https://ebookgate.com


More products digital (pdf, epub, mobi) instant
download maybe you interests ...

Java Programming From Problem Analysis to Program


Design 4th Edition D. S. Malik

https://ebookgate.com/product/java-programming-from-problem-
analysis-to-program-design-4th-edition-d-s-malik/

C Programming From Problem Analysis to Program Design


5th 5th Edition D. S. Malik

https://ebookgate.com/product/c-programming-from-problem-
analysis-to-program-design-5th-5th-edition-d-s-malik/

C Programming Program design including data structures


5ed. Edition Malik D.S.

https://ebookgate.com/product/c-programming-program-design-
including-data-structures-5ed-edition-malik-d-s/

C Programming Program Design Including Data Structures


7th Edition D. S. Malik

https://ebookgate.com/product/c-programming-program-design-
including-data-structures-7th-edition-d-s-malik/
C Programming Program Design Including Data Structures
6th Edition D. S. Malik

https://ebookgate.com/product/c-programming-program-design-
including-data-structures-6th-edition-d-s-malik/

Fixed Income Analysis 4th edition Edition Barbara S


Petitt

https://ebookgate.com/product/fixed-income-analysis-4th-edition-
edition-barbara-s-petitt/

Programming in Objective C 4th Edition Stephen Kochan

https://ebookgate.com/product/programming-in-objective-c-4th-
edition-stephen-kochan/

C Programming Data Structures 4th Edition E.


Balagurusamy

https://ebookgate.com/product/c-programming-data-structures-4th-
edition-e-balagurusamy/

Reading the Middle Ages From c 900 to c 1500 3. ed.


Edition Barbara H. Rosenwein

https://ebookgate.com/product/reading-the-middle-ages-
from-c-900-to-c-1500-3-ed-edition-barbara-h-rosenwein/
C# PROGRAMMING:
FROM PROBLEM ANALYSIS TO PROGRAM DESIGN

FOURTH EDITION

Copyright 2013 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s).
Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
This is an electronic version of the print textbook. Due to electronic rights restrictions,
some third party content may be suppressed. Editorial review has deemed that any suppressed
content does not materially affect the overall learning experience. The publisher reserves the right
to remove content from this title at any time if subsequent rights restrictions require it. For
valuable information on pricing, previous editions, changes to current editions, and alternate
formats, please visit www.cengage.com/highered to search by ISBN#, author, title, or keyword for
materials in your areas of interest.

Copyright 2013 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s).
Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
Copyright 2013 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s).
Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
C# PROGRAMMING:
FROM PROBLEM ANALYSIS TO PROGRAM DESIGN

FOURTH EDITION

BARBARA DOYLE

Australia l Brazil l Japan l Korea l Mexico l Singapore l Spain l United Kingdom l United States

Copyright 2013 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s).
Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
C# Programming: From Problem Analysis © 2014 Cengage Learning
to Program Design, Fourth Edition
ALL RIGHTS RESERVED. No part of this work covered by the copyright
Barbara Doyle herein may be reproduced, transmitted, stored or used in any form or
by any means graphic, electronic, or mechanical, including but not
Executive Editor: Kathleen McMahon
limited to photocopying, recording, scanning, digitizing, taping, Web
Senior Product Manager: Alyssa Pratt distribution, information networks, or information storage and
Editorial Assistant: Sarah Ryan retrieval systems, except as permitted under Section 107 or 108 of the
1976 United States Copyright Act, without the prior written permission
Content Project Manager: Jennifer Feltri-George
of the publisher.
Art Director: Cheryl Pearl, GEX
Manufacturing Planner: Julio Esperas
Cover Designer: GEX Publishing Services For product information and technology assistance, contact us at
Cover Photo: ©iurii /Shutterstock Cengage Learning Customer & Sales Support,
www.cengage.com/support
Copyeditor: Andrea Schein
Indexer: Sharon Hilgenberg For permission to use material from this text or product,
submit all requests online at cengage.com/permissions
Compositor: Integra
Further permissions questions can be e-mailed to
[email protected]

Library of Congress Control Number: 2013932312


ISBN-13: 978-1-285-09626-1
ISBN-10: 1-285-09626-6
Cengage Learning
20 Channel Center Street
Boston, MA 02210
USA

Some of the product names and company names used in this book have
been used for identification purposes only and may be trademarks or
registered trademarks of their respective manufacturers and sellers.
Any fictional data related to persons or companies or URLs used
throughout this book is intended for instructional purposes only. At the
time this book was printed, any such data was fictional and not
belonging to any real persons or companies.
Cengage Learning reserves the right to revise this publication and
make changes from time to time in its content without notice.
The programs in this book are for instructional purposes only. They
have been tested with care, but are not guaranteed for any
particular intent beyond educational purposes. The author and the
publisher do not offer any warranties or representations, nor do they
accept any liabilities with respect to the programs.
Cengage Learning is a leading provider of customized learning
solutions with office locations around the globe, including
Singapore, the United Kingdom, Australia, Mexico, Brazil, and Japan.
Locate your local office at: www.cengage.com/global
Cengage Learning products are represented in Canada by Nelson
Education, Ltd.
To learn more about Cengage Learning visit
www.cengage.com.
Purchase any of our products at your local college store or at our
preferred online store: www.cengagebrain.com

Printed in the United States of America


1 2 3 4 5 6 7 19 18 17 16 15 14 13
Copyright 2013 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s).
Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
B RIEF C ONTENTS

Neale Cousland / Shutterstock.com

PREFACE xxi

1. Introduction to Computing and Programming 1

2. Data Types and Expressions 65

3. Methods and Behaviors 131

4. Creating Your Own Classes 191

5. Making Decisions 247

6. Repeating Instructions 313

7. Arrays 383

8. Advanced Collections 439

9. Introduction to Windows Programming 493

10. Programming Based on Events 577

11. Advanced Object-Oriented Programming Features 691

12. Debugging and Handling Exceptions 775

13. Working with Files 837

14. Working with Databases 893

15. Web-Based Applications 979

Copyright 2013 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s).
Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
vi | C# Programming: From Problem Analysis to Program Design, Fourth Edition

APPENDIX A Visual Studio Configuration 1083

APPENDIX B Code Editor Tools 1099

APPENDIX C Character Sets 1111

APPENDIX D Operator Precedence 1113

APPENDIX E C# Keywords 1115

GLOSSARY 1117

INDEX 1131

Copyright 2013 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s).
Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
TABLE OF C ONTENTS

Neale Cousland / Shutterstock.com

Preface xxi

INTRODUCTION TO COMPUTING AND PROGRAMMING 1


1 History of Computers 2
System and Application Software 4
System Software 4
Application Software 6
Software Development Process 6
Steps in the Program Development Process 7
Programming Methodologies 13
Structured Procedural Programming 14
Object-Oriented Programming 16
Evolution of C# and .NET 19
Programming Languages 19
.NET 21
Why C#? 23
Types of Applications Developed with C# 24
Web Applications 24
Windows Applications 25
Console Applications 26
Exploring the First C# Program 27
Elements of a C# Program 28
Comments 28
Using Directive 30
Namespace 32
Class Definition 32

Copyright 2013 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s).
Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
viii | C# Programming: From Problem Analysis to Program Design, Fourth Edition

Main( ) Method 33
Method Body Statements 34
Compiling, Building, and Running an Application 38
Typing Your Program Statements 38
Compilation and Execution Process 39
Compiling the Source Code Using Visual Studio IDE 39
Debugging an Application 45
Syntax Errors 45
Run-time Errors 47
Creating an Application 47
Coding Standards 52
Pseudocode 52
Resources 53
Quick Review 53
Exercises 56
Programming Exercises 61

DATA TYPES AND EXPRESSIONS 65


2 Data Representation 66
Bits 66
Bytes 66
Binary Numbering System 66
Character Sets 69
Kilobyte, Megabyte, Gigabyte, Terabyte, Petabyte. . . 70
Memory Locations for Data 70
Identifiers 71
Variables 75
Literal Values 75
Types, Classes, and Objects 76
Types 76
Classes 77
Objects 78
Predefined Data Types 79
Value Types 80

Copyright 2013 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s).
Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
Table of Contents | ix

Integral Data Types 82


Floating-Point Types 85
Decimal Types 86
Boolean Variables 87
Declaring Strings 88
Making Data Constant 88
Assignment Statements 89
Basic Arithmetic Operations 92
Increment and Decrement Operations 95
Compound Operations 98
Order of Operations 100
Mixed Expressions 102
Casts 103
Formatting Output 104
Width Specifier 109
Coding Standards 119
Naming Conventions 119
Spacing Conventions 119
Declaration Conventions 120
Resources 120
Quick Review 120
Exercises 121
Programming Exercises 127

METHODS AND BEHAVIORS 131


3 Anatomy of a Method 132
Modifiers 134
Return Type 137
Method Name 138
Parameters 138
Method Body 139
Calling Class Methods 141
Predefined Methods 143
Writing Your Own Class Methods 157
Void Methods 157
Value-Returning Method 159
Copyright 2013 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s).
Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
x | C# Programming: From Problem Analysis to Program Design, Fourth Edition

Types of Parameters 164


Named and Optional Parameters 169
Default Values with Optional Parameters 170
Named Parameters 171
Coding Standards 180
Naming Conventions 180
Spacing Conventions 180
Declaration Conventions 180
Commenting Conventions 181
Resources 181
Quick Review 181
Exercises 182
Programming Exercises 189

CREATING YOUR OWN CLASSES 191


4 The Object Concept 192
Private Member Data 193
Constructor 197
Writing Your Own Instance Methods 200
Accessor 200
Mutators 201
Other Instance Methods 202
Property 202
ToString( ) Method 204
Calling Instance Methods 206
Calling the Constructor 206
Calling Accessor and Mutator Methods 208
Calling Other Instance Methods 209
Testing Your New Class 210
Coding Standards 235
Naming Conventions 235
Classes 235
Properties 235
Methods 236

Copyright 2013 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s).
Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
Table of Contents | xi

Constructor Guidelines 236


Spacing Conventions 236
Resources 236
Quick Review 237
Exercises 238
Programming Exercises 244

MAKING DECISIONS 247


5 Boolean Expressions 248
Boolean Results 248
Conditional Expressions 249
Equality, Relational, and Logical Tests 250
Short-Circuit Evaluation 258
Boolean Data Type 260
if. . .else Selection Statements 261
One-Way if Statement 261
Two-Way if Statement 266
Nested if. . .else Statement 273
Switch Selection Statements 279
Ternary Operator ? : 283
Order of Operations 285
Coding Standards 298
Guidelines for Placement of Curly Braces 299
Guidelines for Placement of else with Nested if Statements 299
Guidelines for Use of White Space with a Switch Statement 299
Spacing Conventions 300
Advanced Selection Statement Suggestions 300
Resources 300
Quick Review 301
Exercises 302
Programming Exercises 310

Copyright 2013 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s).
Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
xii | C# Programming: From Problem Analysis to Program Design, Fourth Edition

REPEATING INSTRUCTIONS 313


6 Why Use a Loop? 314
Using the While Statement 314
Counter-Controlled Loop 316
Sentinel-Controlled Loop 321
State-Controlled Loops 332
Using the for Statement Loop 335
Using the Foreach Statement 342
Using the Do...while Structure 343
Nested Loops 346
Recursive Calls 351
Unconditional Transfer of Control 354
Continue Statement 355
Deciding Which Loop to Use 356
Coding Standards 370
Guidelines for Placement of Curly Braces 371
Spacing Conventions 371
Advanced Loop Statement Suggestions 371
Resources 372
Quick Review 372
Exercises 373
Programming Exercises 379

ARRAYS 383
7 Array Basics 384
Array Declaration 385
Array Initializers 388
Array Access 390
Sentinel-Controlled Access 394
Using Foreach with Arrays 395
Array Class 396
Arrays as Method Parameters 401
Pass by Reference 401
Array Assignment 405
Params Parameters 406

Copyright 2013 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s).
Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
Table of Contents | xiii

Arrays in Classes 408


Array of User-Defined Objects 410
Arrays as Return Types 410
Coding Standards 428
Guidelines for Naming Arrays 428
Advanced Array Suggestions 428
Resources 429
Quick Review 429
Exercises 430
Programming Exercises 437

ADVANCED COLLECTIONS 439


8 Two-Dimensional Arrays 440
Rectangular Array 440
Jagged Array 450
Multidimensional Arrays 450
ArrayList Class 455
String Class 459
Other Collection Classes 465
BitArray 466
Hashtable 467
Queue 469
Stack 470
Coding Standards 479
Guidelines for Naming Collections 479
Advanced Array Suggestions 479
Resources 479
Quick Review 480
Exercises 481
Programming Exercises 488

INTRODUCTION TO WINDOWS PROGRAMMING 493


9 Contrasting Windows and Console Applications 494
Graphical User Interfaces 496

Copyright 2013 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s).
Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
xiv | C# Programming: From Problem Analysis to Program Design, Fourth Edition

Elements of Good Design 500


Consistency 500
Alignment 500
Avoid Clutter 501
Color 501
Target Audience 501
Using C# and Visual Studio to Create Windows-Based
Applications 502
Windows Forms 505
Windows Forms Properties 505
Inspecting the Code Generated by Visual Studio 511
Windows Forms Events 515
Controls 517
Placing, Moving, Resizing, and Deleting Control Objects 520
Methods and Properties of the Control Class 521
Derived Classes of the System.Windows.Forms.Control Class 524
Coding Standards 567
Guidelines for Naming Controls 567
Resources 567
Quick Review 568
Exercises 569
Programming Exercises 574

PROGRAMMING BASED ON EVENTS 577


10 Delegates 578
Defining Delegates 578
Creating Delegate Instances 579
Using Delegates 580
Relationship of Delegates to Events 583
Event Handling in C# 583
Event-Handler Methods 584
ListBox Control Objects 585
Creating a Form to Hold ListBox Controls 585
ListBox Event Handlers 588
Multiple Selections with a ListBox Object 589
Copyright 2013 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s).
Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
Table of Contents | xv

ComboBox Control Objects 601


Adding ComboBox Objects 602
Handling ComboBox Events 602
Registering a KeyPress Event 603
Programming Event Handlers 603
MenuStrip Control Objects 605
Adding Menus 606
Adding Predefined Standard Windows Dialog Boxes 610
CheckBox and RadioButton Objects 618
CheckBox Objects 618
Adding CheckBox Objects 619
Registering CheckBox Object Events 619
Wiring One Event Handler to Multiple Objects 621
GroupBox Objects 622
RadioButton Objects 622
Adding RadioButton Objects 622
Registering RadioButton Object Events 624
Windows Presentation Foundation (WPF) 633
TabControl Objects 639
Coding Standards 680
Resources 680
Quick Review 680
Exercises 682
Programming Exercises 688

ADVANCED OBJECT-ORIENTED PROGRAMMING


11 FEATURES 691
Object-Oriented Language Features 692
Component-Based Development 693
Inheritance 694
Inheriting from the Object Class 695
Inheriting from Other .NET FCL Classes 695
Creating Base Classes for Inheritance 696
Overriding Methods 699
Creating Derived Classes 700
Copyright 2013 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s).
Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
xvi | C# Programming: From Problem Analysis to Program Design, Fourth Edition

Making Stand-Alone Components 705


Creating a Client Application to Use the DLL 715
Using ILDASM to View the Assembly (Optional) 719
Abstract Classes 721
Abstract Methods 721
Sealed Classes 724
Sealed Methods 725
Partial Classes 725
Creating Partial Classes 726
Interfaces 726
Defining an Interface 727
Implementing the Interface 728
.NET Framework Interfaces 733
Polymorphism 734
Polymorphic Programming in .NET 736
Generics 737
Generic Classes 737
Generic Methods 741
Dynamic 742
Dynamic data type 743
var data type 744
Coding Standards 764
Resources 765
Quick Review 765
Exercises 767
Programming Exercises 772

DEBUGGING AND HANDLING EXCEPTIONS 775


12 Errors 776
Run-Time Errors 777
Debugging in C# 778
Exceptions 786
Raising an Exception 790
Bugs, Errors, and Exceptions 791

Copyright 2013 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s).
Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
Table of Contents | xvii

Exception-Handling Techniques 793


Try. . .Catch. . .Finally Blocks 794
Exception Object 798
Exception Classes 799
Derived Classes of the Base Exception Class 799
ApplicationException Class 800
SystemException Class 801
Filtering Multiple Exceptions 802
Throwing an Exception 809
Input Output (IO) Exceptions 810
Coding Standards 828
Resources 829
Quick Review 829
Exercises 830
Programming Exercises 835

WORKING WITH FILES 837


13 System.IO Namespace 838
File and Directory Classes 840
File Class 840
Directory Class 844
FileInfo and DirectoryInfo Classes 845
File Streams 848
Writing Text Files 851
Reading Text Files 856
Adding a Using Statement 860
Random Access 863
BinaryReader and BinaryWriter Classes 863
Other Stream Classes 869
FileDialog Class 870
Coding Standards 884
Resources 884
Quick Review 884
Exercises 885
Programming Exercises 890

Copyright 2013 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s).
Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
xviii | C# Programming: From Problem Analysis to Program Design, Fourth Edition

WORKING WITH DATABASES 893


14 Database Access 894
Database Management Systems 894
ADO.NET 895
Data Providers 896
Connecting to the Database 899
Retrieving Data from the Database 901
Processing the Data 905
Updating Database Data 913
Using Datasets to Process Database Records 913
Data Source Configuration Tools 921
Add New Data Source 921
Dataset Object 931
TableAdapterManager 941
DataSet Designer 942
Connecting Multiple Tables 953
Displaying Data Using Details View 959
Language-Integrated Query (LINQ) 962
Query Expressions 963
Implicitly Typed Local Variables 966
LINQ with Databases 966
LINQ to SQL 968
Coding Standards 969
Resources 969
Quick Review 969
Exercises 971
Programming Exercises 976

WEB-BASED APPLICATIONS 979


15 Web-Based Applications 980
Web Programming Model 980
Static Pages 981
Dynamic Pages 984

Copyright 2013 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s).
Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
Table of Contents | xix

ASP.NET 986
Visual Studio for Web Development 986
ASP.NET Programming Models 987
Web Forms Page 988
Creating an ASP.NET Web Forms Site 988
Master Pages 993
Cascading Style Sheet (CSS) 997
ASP.NET Empty Web Site 1001
Controls 1004
HTML Controls 1004
HTML Server Controls 1008
Web Forms Standard Server Controls 1012
Available Web Forms Controls 1012
Web Forms Controls of the Common Form Type 1014
Adding Common Form-Type Controls 1018
Validation, Custom, and Composite Controls 1021
Validation Controls 1021
Calendar Control 1026
GridView Control 1033
AccessDataSource 1039
Using Visual Tools to Connect 1040
Setting the Visibility Property 1045
Other Controls 1047
Web Services 1050
Web Services Protocols 1050
Windows Communication Foundation (WCF) 1052
Smart Device Applications (Optional) 1052
Windows 7.x Phone 1053
Silverlight 1054
Creating a Smart Device Application for Windows 7.x Phones 1054
Windows 8 Phone Apps 1061
Creating a Windows 8 Phone App 1063
XML 1064
Code-Behind File 1065
XAML Code 1067
Running the App 1068
Deploying to an Emulator 1068
Deploying to a Device 1071
Copyright 2013 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s).
Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
xx | C# Programming: From Problem Analysis to Program Design, Fourth Edition

Coding Standards 1073


Resources 1074
Quick Review 1075
Exercises 1076
Programming Exercises 1081

APPENDIX A: VISUAL STUDIO CONFIGURATION 1083


Customizing the Development Environment 1083
Environment 1085
Projects and Solutions 1088
Text Editor 1089
Debugging 1093
HTML Designer 1093
Windows Forms Designer 1094
Other Options Settings 1095
Choose Toolbox Items 1096
Customize the Toolbars 1097

APPENDIX B: CODE EDITOR TOOLS 1099


Code Snippets 1099
Refactoring 1101
Extrace Method 1102
Rename 1104
Other Refactoring Options 1105
Working with Class Diagrams 1106
Class Details View 1107
Using the Class Diagram to Add Members 1108
Other Code Editor Tips 1109

APPENDIX C: CHARACTER SETS 1111

APPENDIX D: OPERATOR PRECEDENCE 1113

APPENDIX E: C# KEYWORDS 1115

GLOSSARY 1117

INDEX 1131

Copyright 2013 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s).
Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
P REFACE

Neale Cousland / Shutterstock.com

C# Programming: From Problem Analysis to Program Design requires no previous introduction to


programming and only a mathematical background of high school algebra. The book uses C#
as the programming language for software development; however, the basic programming
concepts presented can be applied to a number of other languages. Instead of focusing on the
syntax of the C# language, this book uses the C# language to present general programming
concepts. It is the belief of the author that once you develop a thorough understanding of one
programming language, you can effectively apply those concepts to other programming
languages.

Why C#?
C# has gained tremendous popularity in the industry. C# is a true object-oriented language
that includes a rich set of instruction statements. C# was the language used for development
of much of .NET, the Microsoft programming paradigm that includes a collection of
more than 2,000 predefined classes that make up the Framework Class Library (FCL).
Thus, C# has access to a large collection of predefined classes similar to those available to
Java. C# provides tools that make it easy to create graphical user interfaces—similar to the
tools Visual Basic programmers have employed for years. C# also provides the pure data
crunching horsepower to which C/C++ programmers have become accustomed. But
unlike other languages, C# was designed from scratch to accommodate Internet and
Windows applications. C# is an elegant and simple object-oriented language that allows
programmers to build a breadth of applications. For these reasons, C# was chosen as the
language for this book.

Going Beyond the Traditional CS1 Course


This book was written for the Computer Science 1 (CS1) student and includes all of the
basic programming constructs normally covered in the traditional CS1 foundation course
for the Computer Science curriculum. Readers begin developing applications
immediately in the first chapter. It includes lots of examples and figures illustrating
basic concepts. A heavy emphasis on illustrating the visual tools that can be used to
create applications is included in this edition. But this book goes beyond what is

Copyright 2013 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s).
Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
xxii | C# Programming: From Problem Analysis to Program Design, Fourth Edition

traditionally found in most CS1 textbooks and, because of the inclusion of a number of
advanced applications, this textbook could also be used in an intermediate course for
students who have already been exposed to some programming concepts.

Advanced Topics
After building a solid programming foundation, this book presents rapid application
development techniques that can be used to build a number of advanced types of
applications including Windows, data-driven applications using a database, and Web and
mobile applications for smart devices. Generics, delegates, ArrayLists, dynamic data types,
abstract classes, interfaces, and many advanced object-oriented concepts are introduced.
Readers retrieve data from files and store data both to sequential and binary files. Solutions
involving multidimensional arrays and other advanced collection classes are demonstrated.
Illustrating the drag-and-drop construction approach used with Visual Studio, Windows and
Web applications are created. Readers are introduced to the event-driven programming
model, which is based on interactively capturing and responding to user input on Windows
and Web forms. Class libraries, Windows Forms applications, and Windows Presentation
Foundation client applications are created. Two full chapters are devoted to programming
based on events and then those topics are integrated throughout the remainder of the
book. Readers are introduced to ASP.NET for Web applications and ADO.NET for
working with databases.
For first-time programmers, this book is unusual in introducing applications that retrieve
and update data in databases such as those created using Microsoft Access. A number of
visual development tools are illustrated to connect to data sources. Other interesting
topics include retrieving data using Language-Integrated Query (LINQ), developing
stand-alone .dll components (class libraries), and programming applications for mobile
devices such as tablets and smart phones. All of these advanced features are discussed
after the reader has gained a thorough understanding of the basic components found in
programming languages.

Changes in the Fourth Edition


C# Programming: From Problem Analysis to Program Design, Fourth Edition, has been revised and
updated to reflect the latest release of Visual Studio 2012 and C#. Exception-handling
techniques are introduced much earlier and incorporated into exercises throughout the
book. Additional advanced object-oriented concepts are included. Each chapter includes
new programming exercises not seen in previous editions. All example programs, exercises,
and the solution set have been updated using Visual Studio 2012. All screenshots are updated
to the Visual Studio 2012 IDE. Readers are introduced to Visual Studio’s mobile Software
Development Kit for creating applications for smart devices. Apps are created for both
Windows 7.x and Windows 8 phones. The following summarizes some of the changes in
the fourth edition.

Copyright 2013 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s).
Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
Preface | xxiii

1. Early introduction of exception-handling techniques with numbered Examples


modified to integrate those concepts throughout the book.
2. New Windows Forms controls introduced for creating Windows applications.
3. Guided illustrations of developing smart device apps for the Windows Phone.
4. New Programming Exercises not found in previous editions added to every
chapter. Solutions to all exercises developed by the author.
5. Expanded Coding Standards section at the end of each chapter summarizes C#
key development standards and guidelines.
6. Increased list of Internet sites added at the end of each chapter in the Resources
section for readers to explore.
7. Additional Notes added throughout the book highlighting tips and ‘‘catch you’’
types of topics.
8. Expanded Glossary provides a reference for keywords tagged throughout
the book.
9. Revised Appendices include special sections, Customizing the Visual Studio
Development Environment and Code Editor Tools, with updated illustrations
and figures.

Approach
A problem-solving methodology based on object-oriented software development is
introduced early and used throughout the book. Programming Examples are presented at
the end of each chapter, and each example follows a consistent approach: analyzing the
problem specifications, designing a solution, implementing the design, and verifying or
validating the solution structures.
The author believes that the best way to learn to program is to experience programming. This
assumption drives the material presented in this textbook. As new concepts are introduced,
they are described using figures and illustrations. Examples are shown and discussed as they
relate to the concept being presented. With a hands-on approach to learning, readers practice
and solidify the concepts presented by completing the end of the chapter exercises. Readers
are also encouraged throughout the book to explore and make use of the more than 2,000
classes that make up the Framework Class Library (FCL).
Every chapter begins with a list of objectives and a short overview of the previous
chapter. Text in each chapter is supplemented with figures and tables to help visual
learners grasp the concepts being presented. Each chapter is sprinkled with useful tips and
hints as NOTES on the concepts being presented. Code snippets and numbered examples
are embedded as new concepts are introduced in each chapter. In addition, each chapter
contains complete working programs illustrating an application using C#. Every chapter
ends with a Coding Standards section, which provides a summary of acceptable
Copyright 2013 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s).
Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
xxiv | C# Programming: From Problem Analysis to Program Design, Fourth Edition

conventions or guidelines pertaining to the chapter’s topics that focus on style issues.
A list of Web sites for readers to explore is included in a special Resources section at
the end of each chapter. A summary of the major points covered in that chapter and
review exercises in both objective and subjective formats are included. Every chapter
contains 10 programming exercises that give readers an opportunity to experience
programming.

Using this Book for Two Different Courses


Although this book is primarily intended for a beginning programming course, it will also
work well in an intermediate course. For courses introducing students to programming,
Chapters 1 through 8 should be covered in detail. Depending on how quickly students are
able to grasp the material, the course could end in any of the chapters following Chapter 8. For
example, ending with Chapter 9, Introduction to Windows Programming, would give
students an opportunity to get excited about continuing their work in programming in
upcoming semesters.
For an intermediate course, where the first course was taught using a different language, the
last part of Chapter 1 along with Appendices A and B could be read to orient the readers to
running an application using Visual Studio. Students could be encouraged to scan Chapters 2
through 7 and review Chapter 8 more extensively. Scanning these chapters, students could
compare and contrast the details of the C# language with the programming languages they
already know.
For the intermediate course where the first course was taught using C#, Chapters 4, 7, and 8
should be reviewed, because topics covered in these chapters—Creating your Own Classes
and Arrays—are often more difficult for the student to grasp. The remainder of the book
beginning in Chapter 9 would be included for the intermediate course.

Overview of the Chapters


Chapter 1 briefly reviews the history of computers and programming languages including the
evolution of C# and .NET. This chapter explains the difference between structured and
object-oriented programming and includes the software development methodology used
throughout the remainder of the book. This chapter describes the different types of
applications that can be developed using C#. It discusses the basic elements found in a C#
program and illustrates how to compile, run, and debug an application.
The focus in Chapter 2 is data types and expressions. Readers gain an understanding of how
types, classes, and objects are related. They also learn how to perform arithmetic procedures on
the data, how to display formatted data, and how expressions are evaluated using operator
precedence. Chapter 3 extends the manipulation of the data through introducing methods and
behaviors of the data. Readers learn to write statements that call methods and to write their
own class methods. They learn how to pass arguments to methods that return values and to
those that do not.

Copyright 2013 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s).
Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
Preface | xxv

Readers learn to create their own classes in Chapter 4. This chapter introduces the
components of a class including the data, property, and method members. Special methods,
including constructors, are written.
Chapters 5 and 6 introduce control structures that alter the sequential flow of execution.
Selection control constructs are introduced in Chapter 5. One-way, multiway, switch, and
ternary operators used to make decisions are illustrated. Looping is introduced in Chapter 6.
The rich set of iteration operators including while, for, do while, and foreach are
explored. Recursive solutions are also explored.
Chapter 7 discusses arrays. This chapter describes how to declare and perform compile-time
initialization of array elements. The Array class and its many members are introduced.
Methods of the string and ArrayList classes are included in Chapter 8. Multidimensional
arrays and other collection classes, including stacks, queues, and hash tables are also
introduced in Chapter 8.
Chapters 9 and 10 present a different way of programming, which is based on interactively
responding to events. A number of classes in the FCL that are used to create Windows
applications are introduced. Elements of good design are discussed in Chapter 9. Delegates
are also explored in Chapter 9. Visual Studio’s drag-and-drop approach to rapid application
development is introduced and used in these chapters. The Windows Presentation Foundation
(WPF) is also introduced in Chapter 10 as an alternative approach to Windows Forms for
creating Windows applications.
Advanced object-oriented programming features are the focus of Chapter 11. Readers are
introduced to component-based development and learn how to create their own class library
files. Inheritance, interfaces, abstract classes, sealed classes, generic types, partial classes, and
polymorphic programming are discussed in detail. Advanced features such as overriding,
overloading, and the use of virtual methods are also included in Chapter 11. Static versus
dynamic typing is also investigated in Chapter 11.
Chapter 12 discusses debugging and exception handling techniques. The chapter introduces
one of the tools available in Visual Studio, the Debugger, which can be used to observe the
run-time environment, take an up-close look at the code, and locate logic errors. The try. . .
catch. . .finally block is discussed for handling exceptions. In addition to discussing .NET
exception classes, custom exceptions are designed.
Chapter 13 presents the basics of creating, opening, closing, reading, and writing files. The
major classes used to work with file and directory systems are introduced. Chapter 14
introduces a number of new namespaces collectively called ADO.NET, which consists of a
managed set of library classes that enables interaction with databases. The chapter illustrates
how ADO.NET classes are used to retrieve and update data in databases. The visual
programming tools and wizards available with Visual Studio, which simplify accessing data,
are covered in this chapter. The Language-Integrated Query (LINQ) is also introduced in
Chapter 14.
The focus of Chapter 15 is on Web applications. Readers explore how the design of Web-
based applications differs from Windows applications. They discover the differences between

Copyright 2013 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s).
Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
xxvi | C# Programming: From Problem Analysis to Program Design, Fourth Edition

static and dynamic Web pages and how HTML and Web server controls differ. Master pages
and Cascading Style Sheets are introduced. Also included in Chapter 15 is an introduction to
mobile applications that can be viewed with small smart devices such as the Windows Phone.
Chapter 15 illustrates how validation controls can be used to check users’ input values and
shows how the ADO.NET classes, introduced in Chapter 14, can also be used with Web
applications to access database records.
Appendix A presents suggestions for customizing the appearance and behavior of the
Integrated Development Environment (IDE). Appendix B discusses the Code Editor
features of Visual Studio. Code snippets and refactoring are described. These new features
improve programmer productivity by reducing the number of keystrokes required to enter
program statements. This appendix also illustrates developing applications visually using class
diagrams. Appendix C lists the Unicode and ASCII (American Standard Code for Information
Interchange) character sets. Appendix D shows the precedence of the C# operators and
Appendix E lists the C# keywords.

Features
Every chapter in this book includes the following features. These features are both conducive
to learning in the classroom and enable you to learn the material at your own pace.
l Multi-color interior design shows accurate C# code and related comments.
l Learning objectives offer an outline of the concepts discussed in detail in the chapter.
l Hundreds of visual diagrams throughout the text illustrate difficult concepts.
l Syntax boxes show the general form for different types of statements.
l Numbered examples illustrate the key concepts with their relevant code, and the code
is often followed by a sample run. An explanation follows that describes the functions
of the most difficult lines of code.
l Notes highlight important facts about the concepts introduced in the chapter.
l Numerous tables are included that describe and summarize information compactly for
easy viewing.
l A Coding Standards section provides a summary of acceptable conventions or guidelines
pertaining to the chapter’s topic. These coding/programming guidelines help ensure
consistency and reduce the number of bugs and errors entered into programming projects.
l Internet sites listed including tutorials that can be used to enhance concepts are
presented in the Resources section.
l Programming Examples are complete programs featured at the end of the chapter. The
examples contain the distinct stages of preparing a problem specification, analyzing the
problem, designing the solution, and coding the solution.
l Quick Reviews offer a summary of the concepts covered in the chapter.

Copyright 2013 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s).
Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
Preface | xxvii

l Exercises further reinforce learning and ensure that students have, in fact, absorbed the
material. Both objective and subjective types of questions are included at the end of
each chapter.
l Programming Exercises challenge students to write C# programs with a specified
outcome.
l The glossary at the end of the book lists nearly four-hundred key terms in alphabetical
order along with definitions for easy reference. Throughout this text the terms set in
bold indicate that they are defined in the glossary.
From beginning to end, the concepts are introduced at a pace that is conducive to learning.
The writing style of this book is simple and straightforward, and it parallels the teaching style of
a classroom. The concepts introduced are described using examples and small programs.
The chapters have two types of programs. The first type includes small programs that are part
of the numbered examples and are used to explain key concepts. This book also features
numerous case studies called Programming Examples. These Programming Examples are
placed at the end of the chapters to pull together many of the concepts presented
throughout the chapter. The programs are designed to be methodical and workable. Each
Programming Example starts with a Problem Analysis and is then followed by the Algorithm
Design. Every step of the algorithm is then coded in C#. In addition to teaching problem-
solving techniques, these detailed programs show the user how to implement concepts in an
actual C# program. Students are encouraged to study the Programming Examples very
carefully in order to learn C# effectively.
All source code and solutions have been written, compiled, and tested by quality assurance
with Visual Studio Professional 2012.
Microsoft Visual C# can be packaged with this text. Please contact your Course
Technology Sales Representative for more information.

Copyright 2013 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s).
Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
FEATURES OF THE BOOK

Numerous visual
diagrams
throughout the
text illustrate
difficult concepts.
Updated screen
shots of what
readers see in
Visual Studio are
also included
throughout the
book.

Multi-color
interior design
shows accurate
C# code and
related
comments.
Throughout the
book, keywords
are shown in blue
and comments
appear in green.

Copyright 2013 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s).
Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
Syntax boxes
show the general
form for different
types of
statements.

Copyright 2013 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s).
Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
Notes provide short quick
tips highlighting important
concepts and features that
might be overlooked.

Non-keyword code appears


in a different font
throughout the text so
readers can quickly
distinguish program
statements from normal
text.

Copyright 2013 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s).
Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
Numbered
examples
illustrate the key
concepts with
their relevant
code, and the
code is often
followed by a
sample run. An
explanation
follows that
describes the
functions of the
most difficult
lines of code.

Copyright 2013 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s).
Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
Programming
Examples are complete
programs featured at
the end of the chapter.
The examples contain
the distinct stages of
preparing a problem
specification,
analyzing the problem,
designing the solution,
and coding the
implementation.

Copyright 2013 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s).
Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
Coding/programming
style guidelines and
suggestions are
featured at the end
of each chapter.

A special Resources
section at the end of
each chapter offers a
number of Web sites
for the reader to
explore.

Quick Review offers


a summary of the
concepts covered in
the chapter.

Copyright 2013 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s).
Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
Exercises further
reinforce learning
and ensure that
students have, in
fact, absorbed the
material. Both
objective and
subjective types of
activities are
included at the end
of each chapter.

Copyright 2013 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s).
Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
Programming
Exercises challenge
students to write C#
programs with a
specified outcome.

Copyright 2013 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s).
Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
xxxvi | C# Programming: From Problem Analysis to Program Design, Fourth Edition

Instructor Resources
The following teaching tools are available for download at our Instructor Companion Site.
Simply search for this text at login.cengage.com. An instructor login is required.
Electronic Instructor’s Manual. The Instructor’s Manual that accompanies this textbook
includes additional instructional material to assist in class preparation, including suggestions for
lecture topics.
ExamView. This textbook is accompanied by ExamView, a powerful testing software
package that allows instructors to create and administer printed, computer (LAN-based), and
Internet exams. ExamView includes hundreds of questions that correspond to the topics
covered in this text, enabling students to generate detailed study guides that include page
references for further review. These computer-based and Internet-testing components allow
students to take exams at their computers, and save the instructor time because each exam is
graded automatically.
PowerPoint Presentations. This book comes with Microsoft PowerPoint slides for each
chapter. These are included as a teaching aid for classroom presentations, either to make
available to students on the network for chapter review, or to be printed for classroom
distribution. Instructors can add their own slides for additional topics that they introduce to
the class.
Source Code for Examples. The complete Visual Studio project files for the examples
included within each chapter are available for instructors and are also posted for students on
www.cengagebrain.com. Individual source code files are stored with a .cs extension inside the
project subdirectory.
Programming Exercises Solution Files. The complete Visual Studio project files for the
solutions to all programming exercises included at the end of the chapters are provided. The
individual source code files are stored with a .cs extension inside the project subdirectory.

Acknowledgments
I would like to express my gratitude for the opportunity to complete the fourth edition of this
book. Like the other editions, it was a huge undertaking for me. Special thanks go out to
Alyssa Pratt, Senior Product Manager at Cengage Learning, for her positive comments,
guidance, and support. She was a pleasure to work with again on this new edition. I am
grateful to the Quality Assurance team members who verified that each of the examples and
exercise solutions worked properly. Also thanks to the Content Manager and Copy Editor,
Jennifer Feltri-George and Andrea Schein, who provided great suggestions as we progressed
with the project.
I am very grateful to the following reviewers for their uplifting comments and suggestions for
improvements:

Copyright 2013 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s).
Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
Preface | xxxvii

Zaina Ajackie: American InterContinental University


Kevin Lertwachara: California Polytechnic State University
Syed Raza: Trenholm State Technical College
Dale Wallentine: Stevens-Henager College
I hope that the reviewers will see that many of their suggestions were implemented. The
textbook is much improved because of their contributions.

Copyright 2013 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s).
Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
Copyright 2013 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s).
Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
Neale Cousland / Shutterstock.com
CHAPTER
1
I NTRODUCTION TO
COMPUTING AND
P ROGRAMMING
I N T H I S C H A P T E R , YO U W I L L :

. Learn about the history of computers


. Learn to differentiate between system and application software
. Learn the steps of software development
. Explore different programming methodologies
. Learn why C# is being used today for software development
. Distinguish between the different types of applications that can
be created with C#
. Explore a program written in C#
. Examine the basic elements of a C# program
. Compile, run, build, and debug an application
. Create an application that displays output
. Work through a programming example that illustrates the
chapter's concepts

All Microsoft screenshots used with permission from Microsoft Corporation.


Copyright 2013 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s).
Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
2 | Chapter 1: Introduction to Computing and Programming

Computers have penetrated every aspect of our society and have greatly simplified many
tasks. Can you picture yourself typing a paper on an electric typewriter? Would you use an
eraser to make your corrections? Would you start from scratch to increase or decrease
your margins or line spacing? Can you imagine living in an age without electronic
messaging or e-mail capability? What would you do without an automatic teller machine
(ATM) in your neighborhood?
Computers have become such an integral part of our lives that many of their functions are
taken for granted. Yet, only a few years ago, mobile apps, text messaging and cloud
computing were unknown. Social media technologies like internet forums, weblogs,
wikis, podcasts and social networks like Facebook were unknown. In 2012 social media
became one of the most powerful sources for news updates through platforms like Twitter
and Facebook. Advances in computing are occurring every day, and the programs that are
loaded on your computer have become very complex. The technology of wireless
communication is advancing quickly. Expectations are that tablet sales will grow by 200
percent through 2016. Over 100 million units will be sold in 2012. For most consumers,
tablets are not replacements for their conventional computers, but are added devices
they’ll purchase. Mobile applications for smartphones, pocket and tablet PCs, and other
handheld wireless computers are increasingly in demand. To reach this level of
complexity, software development has gone through a number of eras, and today
technical advances accumulate faster and faster. What new types of computer services
and programs will be integral to our daily lives in the future? This book focuses on
creating software programs. Before beginning the journey into software development, a
historical perspective on computing is included to help you see the potential for
advancements that awaits you.

History of Computers
Computing dates back some 5000 years. Many consider the abacus to be the first computer.
Used by merchants of the past and present for trading transactions, the abacus is a calculating
device that uses a system of sliding beads on a rack for addition and subtraction.
In 1642, another calculating device, called the Pascaline, was created. The Pascaline had
eight movable dials on wheels that could calculate sums up to eight figures long. Both the
abacus and Pascaline could perform only addition and subtraction. It was not until the
1830s that the first general-purpose computer, the Analytical Engine, was available.
Charles Babbage and his assistant, Lady Augusta Ada Bryon, Countess of Lovelace,
designed the Analytical Engine. Although it was very primitive by today’s standards, it
was the prototype for what is known today as a general-purpose computer. The Analytical
Engine included input devices, memory storage, a control unit that allowed processing
instructions in any sequence, and output devices.

Copyright 2013 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s).
Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
History of Computers | 3

In the 1980s, the U.S. Defense Department named the Ada programming language in honor 1
of Lady Lovelace. She has been called the world’s first programmer. Controversy surrounds
her title. Lady Byron was probably the fourth or fifth person to write programs. She did
programming as a student of Charles Babbage and reworked some of his calculations.

Many computer historians believe the present day to be in the fifth generation of modern
computing. Each era is characterized by an important advancement. In the mid-1940s, the
Second World War, with its need for strategic types of calculations, spurred on the first
generation of general-purpose machines. These large, first-generation computers were
distinguished by the use of vacuum tubes. They were difficult to program and limited in
functionality. The operating instructions were made to order for each specific task.
The invention of the transistor in 1956 led to second-generation computers, which were
smaller, faster, more reliable, and more energy efficient than their predecessors. The
software industry was born during the second generation of computers with the
introduction of FORTRAN and COBOL.
The third generation, 1964–1971, saw computers become smaller, as transistors were
squeezed onto small silicon discs (single chips), which were called semiconductors.
Operating systems, as they are known today, which allowed machines to run many
different programs at once, were also first seen in third-generation systems.
As time passed, chips kept getting smaller and capable of storing more transistors, making
computers more powerful and less expensive. The Intel 4004 chip, developed in 1971,
placed the most important components of a computer (central processing unit, memory,
and input and output controls) on a minuscule chip about half the size of a dime. Many
household items such as microwave ovens, television sets, and automobiles benefited from
the fourth generation of computing.
During the fourth generation, computer manufacturers tried to bring computing to
general consumers. In 1981, IBM introduced its personal computer (PC). The 1980s
saw an expansion in computer use as clones of the IBM PC made the personal computer
even more affordable. We also saw the development of Graphical User Interfaces (GUIs)
and the mouse as a handheld input device. The number of personal computers in use more
than doubled from two million in 1981 to 5.5 million in 1982. Ten years later, 65 million
PCs were in use.

According to the October 2010 U.S. Census Bureau’s Current Population Survey, released
in July 2012, over 76% of households in the United States had computers.

Defining a fifth generation of systems is somewhat difficult because the generation is still
young. Computers can now accept spoken word instructions, imitate human reasoning
through artificial intelligence, and communicate with devices instantaneously around the

Copyright 2013 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s).
Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
4 | Chapter 1: Introduction to Computing and Programming

globe by transmitting digital media. Mobile apps are growing. By applying problem-
solving steps, expert systems assist doctors in making diagnoses. Healthcare professionals
are now using handheld devices in patients’ rooms to retrieve and update patient records.
Using handheld devices, drivers of delivery trucks are accessing global positioning systems
(GPS) to verify locations of customers for pickups and deliveries. Sitting at a traffic light,
you can check your e-mail, make airline reservations, remotely monitor and manage
household appliances, and access your checking and savings accounts. Using wireless
networks, students can access a professor’s notes when they enter the classroom.
Major advances in software are anticipated as integrated development environments
(IDEs) such as Visual Studio make it easier to develop applications for the Internet
rapidly. Because of the programmability of the computer, the imagination of software
developers is set free to conjure the computing functions of the future.
The real power of the computer does not lie in the hardware, which comprises the
physical components that make up the system. The functionality lies in the software
available to make use of the hardware. The hardware processes complex patterns of 0s and
1s. The software actually transposes these 0s and 1s into text, images, and documents that
people can read. The next section begins the discussion on software.

System and Application Software


Software consists of programs, which are sets of instructions telling the computer exactly
what to do. The instructions might tell the computer to add up a set of numbers, compare
two names, or make a decision based on the result of a calculation. Just as a cook follows a
set of instructions (a recipe) to prepare a dish, the computer follows instructions without
adding extra salt to perform a useful task. The next sections describe the two major
categories of software: system software and application software.

System Software
System software is loaded when you power on the computer. When thinking of system
software, most people think of operating systems. Operating systems such as Windows 8,
Android, iOS, Windows 7, and Linux are types of programs that oversee and coordinate the
resources on the machine. Included are file system utilities, small programs that take care of
locating files and keeping up with the details of a file’s name, size, and date of creation.
System software programs perform a variety of other functions: setting up directories;
moving, copying, and deleting files; transferring data from secondary storage to primary
memory; formatting media; and displaying data on screens. Operating systems include
communication programs for connecting to the Internet or connecting to output devices
such as printers. They include user interface subsystems for managing the look and feel of
the system.

Copyright 2013 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s).
Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
System and Application Software | 5

Operating systems are one type of system software. They are utility programs that make it 1
easier for you to use the hardware.

Another type of system software includes compilers, interpreters, and assemblers. As you
begin learning software development, you will write instructions for the computer using a
programming language. Modern programming languages are designed to be easy to
read and write. They are called high-level languages because they are written in
English-like statements. The programming language you will be using is C#
(pronounced see sharp). Other high-level computer programming languages include
Visual Basic, FORTRAN, Pascal, C, C++, and Java.
Before the computer can execute the instructions written in a programming language such
as C#, the instructions must be translated into machine-readable format. A compiler
makes this conversion. Figure 1-1 shows what a machine language instruction looks like.

ª 2013 Cengage Learning

FIGURE 1-1 A machine language instruction

Just as the English language has rules for sentence construction, programming languages
such as C# have a set of rules, called syntax, that must be followed. Before translating
code into machine-readable form, a compiler checks for rule violations. Compilers do not
convert any statements into machine language until all syntax errors are removed. Code
can be interpreted as well as compiled. Intepreters translate one statement of code into
machine-readable form and then they execute that line. They then translate the next
instruction, execute it, and so on. Unlike compilers, which look at entire pieces of code,
interpreters check for rule violations line by line. If the line does not contain an error, it
is converted to machine language. Interpreters are normally slower than compilers. Many
languages offer both compilers and interpreters, including C, BASIC, Python, and Lisp.
Assemblers convert the assembly programming language, which is a low-level

Copyright 2013 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s).
Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
6 | Chapter 1: Introduction to Computing and Programming

programming language, into machine code. Low-level programming languages are closer
to hardware. They are not as easy to read or write as high-level programming languages.

Application Software
Application software consists of programs developed to perform a specific task. The
games you might play or the search engines you use on the Internet are types of
application software. Word processors, such as Microsoft Word, are examples of
application software. Word was written to help users create professional looking
documents by including a number of editing and formatting options. Spreadsheets, such
as Microsoft Excel, are types of application software designed to make numerical
calculations and generate charts. Database management systems, such as SQL Server,
Oracle, or Microsoft Access, were designed to organize large amounts of data, so that
reports could easily be generated. Software that generates payroll checks is considered
application software, as is software that helps you register for a class. E-commerce Web
sites with database-driven shopping carts, such as eBay, are forms of application software.
Application software is used by the banking industry to manage your checking and saving
accounts. Programmers use programming languages such as C# to write application
software to carry out specific tasks or to solve specific problems. The programs that you
write from this book will be application software.

Software Development Process


You will soon be writing programs using C#. How do you start? Many beginning
programmers just begin typing without planning or without using any organized
sequence of steps. This often leads to increased development time and solutions that
might not consistently produce accurate results.
Programming is a process of problem solving. Typing the program statements in a
language such as C# is not the hardest part of programming. The most difficult part is
coming up with a plan to solve the problem. A number of different approaches, or
methodologies, are used to solve computer-related problems. Successful problem
solvers follow a methodical approach with each programming project. Figure 1-2
illustrates the organized plan, or methodology, that is used to solve the problems
presented in this book. The following section describes each step.

Copyright 2013 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s).
Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
Software Development Process | 7

ª 2013 Cengage Learning

FIGURE 1-2 Steps in the software development process

Steps in the Program Development Process


1. Analyze the problem. The first step should be directed toward grasping
the problem thoroughly. Analyze precisely what the software is supposed to
accomplish. During this phase, you review the problem specifications,
which describe what the program should accomplish. Specifications often
include the desired output of the program in terms of what is to be
displayed, saved, or printed. If specifications are ambiguous or need clar-
ification, you might need to ask probing questions. If you do not know where
you are going, how will you know when you have arrived at the correct location?

Sometimes one of the most difficult parts of the process is getting clear specifications
from the user. Unless you know what the problem is, there is no way you can solve it. Make
sure you understand the problem definition.

Copyright 2013 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s).
Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
8 | Chapter 1: Introduction to Computing and Programming

A program specification might look like Figure 1-3.

Specialty-sports

$31.95
$41.95 $49.95
$59.95

ª 2013 Cengage Learning


FIGURE 1-3 Program specification sheet for a car rental agency problem

During this first phase, in addition to making sure you understand the problem definition,
you must also review the program inputs. You should ask the following types of questions:
l What kind of data will be available for input?
l What types of values (e.g., whole numbers, alphabetic characters, and
numbers with a decimal point) will be in each of the identified data items?
l What is the domain (range of the values) for each input item?
l Will the user of the program be inputting values?
l If the problem solution is to be used with multiple data sets, are there any
data items that stay the same, or remain constant, with each set?
Before you move to designing a solution, you should have a thorough understanding of
the problem. It might be helpful to verbalize the problem definition. It might help to see
sample input for each of the data items. Figure 1-4 illustrates how the input data items
would be determined during analysis for the car rental agency problem shown in Figure 1-3.
Figure 1-4 shows the identifier, or name of the data item, the type, and the domain of
values for each item.

Copyright 2013 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s).
Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
Software Development Process | 9

Instead of having the user enter the full words of Economy, Intermediate, Full size, or
Speciality Sports, the characters E, I, F, and S could be mapped to those categories. 1

char
(single coded E, I, F, or S

ª 2013 Cengage Learning


character)

FIGURE 1-4 Data for car rental agency

2. Design a solution. Programmers use several approaches, or methods,


during design. Procedural and object-oriented methodologies are the two
most commonly used design methods. Some projects are more easily
solved using one approach than the other. Both of these approaches are
discussed in the next section. The selection of programming language
sometimes weighs in when determining the approach. The C# language
was designed to be very object oriented.
No matter what size the project is, careful design always leads to better
solutions. In addition, careful design normally leads to solutions that can
be produced in shorter amounts of time. A divide-and-conquer
approach can be used with both methodologies. As the name implies,
when you divide and conquer a programming problem, you break the
problem into subtasks. Then, you conquer each of the subtasks by further
decomposing them. This process is also called top-down design.
Detailed models should be developed as input to subsequent phases.
Using the object-oriented approach, the focus is on determining the
data characteristics and the methods or behaviors that operate on the data.
These logical groupings of members (data and behavior) are referred to as
a class. These characteristics are placed in a class diagram. Figure 1-5
contains a class diagram for the problem specification given in Figure 1-3.

Copyright 2013 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s).
Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
10 | Chapter 1: Introduction to Computing and Programming

ª 2013 Cengage Learning


char

FIGURE 1-5 Class diagram of car rental agency

Figure 1-5 is a class diagram divided into three sections with the top portion
identifying the name of the class. The middle portion of a class diagram
always lists the data characteristics. Data representing the type of vehicle to
rent and the number of days for the rental are important to a rental car
agency. The bottom portion of the class diagram shown in Figure 1-5 shows
what actions are to be performed with the data items. ComputeCharges( )
is used to determine the cost of the rental using the type of vehicle and the
number of rental days. You will learn more about class diagrams later in this
chapter. Procedural designs, which are appropriate for simpler problem
definitions, use structure charts to show the hierarchy of modules, and
flowcharts or pseudocode listings to detail the steps for each of the modules.
Algorithms for the behaviors (object oriented) or processes (procedural)
should be developed for both of these methodologies. An algorithm is a
clear, unambiguous, step-by-step process for solving a problem. These
steps must be expressed so completely and so precisely that all details are
included. The instructions in the algorithm should be both simple to
perform and capable of being carried out in a finite amount of time.
Following the steps blindly should result in the same results every time.
An algorithm for ComputeCharges( ) multiplies the number of rental
days by the rate associated with the type of vehicle rented to produce the
rental charge. After the algorithm is developed, the design should be
checked for correctness. One way to do this is to use sample data and
desk check your algorithms by mimicking the computer; in other words,
walking through the computer’s steps. Follow each step precisely, one step
at a time. If the problem involves calculations, use a calculator, and follow
your design statements exactly. It is important when you desk check not
to add any additional steps, unless you go back and revise the algorithm.
During this phase, it might also be helpful to plan and design the look of
the desired output by developing a prototype. A prototype is a mock-up
of screens depicting the look of the final output.
3. Code the solution. After you have completed the design and verified
that the algorithm is correct, you translate the design into source code.

Copyright 2013 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s).
Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
Another random document with
no related content on Scribd:
The Project Gutenberg eBook of Sink or swim?
This ebook is for the use of anyone anywhere in the United States
and most other parts of the world at no cost and with almost no
restrictions whatsoever. You may copy it, give it away or re-use it
under the terms of the Project Gutenberg License included with this
ebook or online at www.gutenberg.org. If you are not located in the
United States, you will have to check the laws of the country where
you are located before using this eBook.

Title: Sink or swim?


a novel; vol. 3/3

Author: Mrs. Houstoun

Release date: December 31, 2023 [eBook #72562]

Language: English

Original publication: London: Tinsley Brothers, 1868

Credits: Sonya Schermann, Chuck Greif and the Online Distributed


Proofreading Team at https://www.pgdp.net (This file was
produced from images generously made available by The
Internet Archive)

*** START OF THE PROJECT GUTENBERG EBOOK SINK OR SWIM?


***
CONTENTS OF VOLUME III
TRANSCRIBER'S NOTE

SINK OR SWIM?
A Novel.

BY THE AUTHOR OF

“RECOMMENDED TO MERCY,”

ETC.

IN THREE VOLUMES.

VOL. III.

LONDON:
TINSLEY BROTHERS, 18 CATHERINE ST. STRAND.
1868.

[The right of translation and reproduction is reserved.]

LONDON:
ROBSON AND SON, GREAT NORTHERN PRINTING WORKS,
PANCRAS ROAD, N.W.
CONTENTS OF VOL. III.
CHAP. PAGE
I. “He comes too near,” etc. 1
II. A Lover found and lost 21
III. What was Honor doing? 36
IV. Mrs. Beacham writes a Letter 46
V. Honor turns rebellious 54
VI. What, sell Rough Diamond! 62
VII. Mea culpa 77
VIII. John Beacham makes a Discovery 87
IX. John proves his Right 104
X. “As well as can be expected” 111
XI. From lively to severe 119
XII. Mrs. Beacham refuses to forget 131
XIII. Arthur cheers up 136
XIV. Arthur finds himself done 146
XV. Misfortunes never come singly 154
XVI. Out at Sea 164
XVII. Honor makes a new Acquaintance 188
XVIII. John discovers his Loss 202
XIX. Another Escape 208
XX. Poor Sophy! 216
XXI. Suspense 227
XXII. John gives way 237
XXIII. Honor receives a Letter 243
XXIV. The Uses of Adversity 259
XXV. Conclusion 274

SINK OR SWIM?
CHAPTER I.

“HE COMES TOO NEAR,” ETC.


The merrie month of May was speeding onward, and with it—fast and
furious—rattling over stones, and dashing over impediments, ran the fierce
strong current of “London life.” There is an intoxicating influence,
especially on the inexperienced, in the rapid motion, the ever-changing
aspect of pleasure, the atmosphere redolent of poisonous influences, that is
breathed by the upper ten thousand in the month of May, in busy, half-mad
London. By none was this insidious influence more perilously undergone
than by the impressionable, weak-nerved woman who, through her own
folly, considerably aided by “circumstances over which she had no control,”
was standing on the very brink of the abyss, the name of which is “ruin.”
It was now the middle of May, and during a swiftly-passing fortnight
Honor Beacham, continuing her course of semi-deception regarding her
father’s condition, and entirely concealing from the husband whom she
believed to be exclusively absorbed in his own pursuits and interests the
fact that her days and nights were spent in one continued round of exciting
pleasure, went on her way—if not rejoicing, at least in a condition of such
delightful mental inebriation, that she found barely sense or time enough to
ask herself the serious question, if the life which she was leading indeed
were joy.
John’s answer to her letter, written under the influence of hurt feeling,
and penned by a man utterly destitute, not only of the art to make a thing
appear the thing it is not, but of l’eloquence du billet in general, was one
exactly calculated to rouse in a high-spirited nature a dormant inclination to
rebel. In it there was an implied right to command, a right solely arrogated
(to Honor’s thinking) by reason of the writer’s indifference to her
proceedings, and scanty appreciation of her merits. “You will come back, I
suppose,”—so wrote the unwise man, who, on his side, had so egregiously
erred in his estimate of character,—“you will come back when you have
had enough of London. I don’t say to you, ‘come home,’ for women that are
made to do the thing they don’t like are, as mother says, not over and above
pleasant in a house. We are uncommon busy, too, just now; there is painting
to be done, and the chintz to be calendered, so perhaps you are as well out
of the way of the bother.”
Poor John! Could Honor have heard the heavy sigh that broke from his
full heart as he closed the letter; could she, above all, have looked into that
heart and read its secret sorrows, she could not have doubted of her
husband’s love; and perhaps, removed from the glamour of Arthur
Vavasour’s presence, from the mesmeric influence of a passion which was
becoming terribly overpowering in its hourly-gathering strength, she might
have been again a happy woman in the simple fashion and the humble
sphere to which she had been brought up. Such a “chance,” however, was
not for the foolish, beautiful woman who, with half-tender words (for, alas,
it had come to that) from her high-bred adorer lingering on her memory,
read the simple letter, which it had cost so much pain to write, in anger and
in bitterness. Tossing it on her toilet-table with an impatient jerk, she told
herself that John did not care for her. It was nothing to him, she said
mentally, whether she stayed away or not; but as she inly spoke the words,
the fingers of her little gauntleted hand—she had just returned from riding
in the Park—dashed away something very like tears that had gathered on
her long lashes and nothing short of the recollection that she was going in a
few hours’ time to dine at Richmond with Arthur Vavasour and a few other
friends of her father’s prevented her (for it would be dreadful to make her
appearance with red eyes) from indulging in the luxury of a “good cry.”
That party to London’s prettiest suburb—an evening’s enjoyment which
was to include a row towards Twickenham and Teddington on the clear,
flowing river, and a delicious dinner after dusk in one of the charming
cabinet particuliers appertaining to the Star and Garter, and opening on its
pleasant gardens, had been for days looked forward to with keen
anticipations of delight by Honor Beacham. They were to proceed thither in
two open “hired carriages,” in one of which was to be seated Honor and the
Colonel’s wife, while Arthur Vavasour and a dull, unobservant Mr. Foley, a
gentleman, like Pope’s women, “with no character at all,” were to occupy
the opposite seats. In the second carriage the party collected was likely to
be of a far more noisy, as well as a more congenial, description. Mrs. Foley
—a lady a little on the wrong side of thirty, and whose animal spirits, being
apt occasionally, as the saying is, to “get the better of her,” were in their full
swing of triumph on such an occasion as a Richmond dinner—arrived at
Stanwick-street punctually as the clock struck four, arrayed in a toilet
which, but for the still more amazing costume of the young lady with whom
she was accompanied, would have decidedly monopolised the attention and
wonder of every female observer in that quiet neighbourhood. Shaking
themselves clear of the straw and tumble, consequent on their cab-drive
from some distant locality, Mrs. Foley and her bright-eyed sister Dora
Tibbets stood on the doorsteps of No. 14, laughing noisily—more noisily
than ladies of their stamp often laugh when no one of the male sex is
present to stir their spirits up to boiling point. Their dresses, as they stood
there in the bright sunshine of a May afternoon, were of the kind better
suited to a wedding breakfast than to a “quiet dinner,” as Fred Norcott had
described it, in the country. Light and fair and frolicsome they looked;
women with more auburn frizzled hair about their heads than could, by the
most lively and charitable imagination, have been supposed to be their own,
with bright pink roses mingling with their hirsute ornaments, and with a
quantum suff. of poudre de riz softening the lustre of their complexions.
“How smart they are!” Honor whispered in dismay to Arthur, as the two
caught a glimpse of the lively sisters from behind the muslin curtain of the
first-front drawing-room.
“Awfully. It’s a bore they’re coming, but if there had been nobody it
would have been worse,” said Arthur, leaning over her chair, and speaking
in the low tones which always went so thrillingly to her heart. “Imagine! I
might have been unable, all this evening, to say one word alone to you. And
we have so few more days, Honor! You say that you cannot expect a much
longer holiday; but tell me—do you never, never think what will become of
me when you are gone?”
“Don’t talk in that way,” she said, one of her crimson blushes speaking
far more eloquently than her words, while she tried to hide her confusion by
carefully drawing on finger after finger of her delicate Paris gloves. “Don’t
talk in that way; I must talk to these people now. You don’t know them, of
course?” And rising gracefully, she went through the ceremony of
introduction which her father deemed it necessary to perform.
The next arrivals (they dashed up to the door in a hansom, and remained
talking up to the balcony during the few minutes that elapsed before the
descent of the major portion of the party) were Mr. Foley, and a young
gentleman of slightly horsey appearance, but who, nevertheless, contrived
to snip his words and lisp as ridiculously as any foolish would-be fine
gentleman in town. Captain Bowles was the son of a general officer, and
was himself, though of small dimensions, and of anything but military
bearing, a soldier. He was plain of feature, with a large mouth and a
beardless face. His appearance was more that of an inferior order of
counter-jumper than of a guardsman; nevertheless he was petted and made
much of, especially by the fair sex. Mrs. Foley and her sister were “fine
women,” and “fast,” so the general’s son—who would have been voted,
under less favourable circumstances, a little snob—was allowed to stand up
before them with his hands in his trousers pockets like a man; and while he
minced his platitudes with graceful ease, was smiled on as fondly as though
he were a hero and a gentleman.
There could scarcely have been found a more good-natured chaperone,
duenna,—call her what you will,—than the Colonel’s lanky wife, seated
opposite to dull, sleepy Mr. Foley, who, by the way, was an individual of no
particular profession, gaining a precarious livelihood as “director” to one or
two doubtful companies, and having a floating capital in the same. Mrs.
Norcott, under cover of her pink parasol, kept up a dozy conversation with
that harmless man of business, while Arthur Vavasour, who had no right
whatever (seeing that his young wife was in the most delicate of situations
—nervous during his absence, and only comforted by the certainty that he
was within call) to be there at all, had—alas for the credit of poor selfish
human nature!—forgotten every duty, and ignored the sacred claims of
wifehood, for the sake of passing a few blissful hours by the side of the
forbidden woman he adored. And she—that other wife, who still, strange as
it may seem, and eke impossible to many, kept a large corner in her heart
for home and duty, and the rough, tender-hearted man she called her
husband—what were her thoughts, her feelings, as the tempter, with his
bold beseeching eyes fixed on her blushing face, told her, in looks more
dangerous still than words, the bewildering, but as yet only half-welcome
truth that she was all the world to him, and that, to gain her love, he would
cast to the four winds of heaven every tie on earth, as well as every hope of
heaven?
For it had come to that with this “fond, foolish,” passionate young man.
Made of the stuff that loves in wild extremes, unused to put a bridle on his
fierce desires, restrained by no sweet early home-affections, the dear love,
mother-love, that bids the profligate, sometimes in his wildest moments, to
go no further—only a myth to him—with a God above but half believed in,
and himself the deity on earth he worshipped—who can wonder that this
man, vigorous with the strength and health of his one-and-twenty years,
should make no effort to resist the devil that, without resistance, would not
flee from him?
“How glad I am that you remembered the Park,” Honor said, as they, the
carriages following at a foot’s pace, sauntered slowly along the beautiful
wooded brow beyond Pembroke Lodge; “I would not have missed this view
for the world.”
They were together now,—those two who had been better far had the
wide seas divided them—those two who could not but have owned that so it
was, had any put the question to them in the rare sober moments which
nineteen and twenty-one, in the heyday of folly and of love, are blessed
with. The rest had strolled away in pairs; so that Arthur could speak as well
as look his love into the bewildering eyes of his friend’s lovely wife.
“Mad,—yes, I suppose I am mad,” he said, in answer to a half-reproach
from his companion; “but who, I ask, would not be mad—mad as you are
beautiful—seeing you as I do, Honor, nearly every day, every hour? It is my
fate—for by the heaven above me I cannot help it—to look upon your
beautiful face, and see you smile, my love, my darling! Ah, do not, for the
love of all that is good and beautiful, be angry with me! From the moment
that I saw you first, Honor, I felt as I never felt before for mortal woman—I
—”
“Don’t say so. All men say that,” put in Honor, who was more versed in
the theory of love-making than its practice, and who, while she felt the
necessity of checking her admirer’s outpourings, was terribly shy and
untutored in the process. “Besides, Mr. Vavasour,”—gathering courage as
she proceeded,—“it is very wicked—terribly wicked, both for you to talk
and for me to listen to such words. There is your wife at home, poor thing,
—I often think of her,—how unhappy she would be could she only guess
that you said such things to any woman as I have just been wicked enough
to listen to!”
Arthur could scarcely repress a sigh as the image of poor neglected
Sophy, stretched on her luxurious couch in the gorgeously-furnished back
drawing-room in Hyde-park-terrace, presented itself to his mind’s eye. “She
knows nothing, guesses nothing,” he said, with an ineffectual effort at
carelessness. “Where ignorance is bliss, you know, it’s worse than folly to
be wise. I suspect there is a Bluebeard’s closet in almost every house, and
as long as women don’t try to look inside, all goes on smoothly.”
For a moment, whilst Arthur was imparting to his fair companion this
result of his worldly experience, her thoughts glanced back to her own
home, and to the marked exception to her lover’s rule which it afforded. At
the Paddocks—and well did Honor know that so it was—there could be
found no hidden chamber barred off from the investigations of the curious.
The wife of true-hearted John Beacham could pry at her own wondering
will into any and every corner of his big warm heart, and find there no
skeleton of the past, no flesh-covered denizen of the present, warning her
with uplifted finger that he was false.
Very guilty she felt for a second or two, and humbled and odious, as the
consciousness of being a vile deceiver sent a blush to her fair cheek, and
checked any answering words that had risen to her tongue. Time, however,
for useful reflection was denied her. The sound of her father’s voice
announcing that it was five o’clock, and that the boats were waiting at the
Castle-stairs, effectually interrupted a reverie of a more wholesome
description than might, under the circumstances, have been expected; and,
reëntering their respective carriages, the party were soon on their way down
the hill so loved by Cockney pleasure-seekers, and so be sung by nature-
worshipping poets.

Once in the large comfortable wherry which had been hired for the
occasion, Arthur found very little opportunity, beyond that of paying the
most devoted attention to her personal comfort, of making himself
agreeable to his lady-love. That there was one subject, at least, besides
herself of real and almost absorbing interest to Arthur Vavasour soon
became evident to Honor; and that subject was the approaching Derby race.
Since her instalment in Stanwick-street, Honor had heard more talk of that
all-important annual event than—horse-breeder’s wife though she was—she
had listened to through all the many months of her married life; and
naturally enough, seeing that the “favourite” was her father’s property, and
that Arthur Vavasour appeared deeply interested in the triumph of Rough
Diamond, the success of that distinguished animal became one of the most
anxious wishes of Mrs. John Beacham’s heart.
“O, I do so hope he’ll win!” she exclaimed enthusiastically; “he is such a
wonderfully beautiful creature. And he has a brother who, they think, will
be more perfect still;—no, not a brother quite, a half-brother, I think he is;
and I used to watch him every day led out to exercise, looking so wild and
lovely. He is only a year old, and his name is Faust; and they say he is quite
sure to be a Derby horse.”
Poor Honor! In her eagerness on the subject, and her intense love of the
animal whose varied charms and excellences were to be seen in such
perfection in her husband’s home, she had been inadvertently “talking
shop” for the amusement of the spurious fine ladies, whose supercilious
glances at each other were not, even by such a novice as Honor Beacham,
to be mistaken. In a moment—for the poison of such glances is as rapid as
it is insidious—two evil spirits, the spirits of anger and of a keen desire to
be avenged, took possession of our heroine. She saw herself despised, and
—so true is it that we cannot scarcely commit the smallest sin without
doing an injury as well to our neighbours as to ourselves—she resolved, to
the utter extinction of the very inferior beauties near her, to make the most
of the wondrous gift of loveliness which she was conscious of possessing.
Hitherto she had “borne her faculties meekly;” the consciousness that she
was, by marriage, without the pale of the “upper ten thousand” had,
together with an innate modesty which was one of her rarest charms, kept
her silent and somewhat subdued when in what is called “company.” It had
required the looks of contempt which she had seen passing between the
well-got-up sisters to rouse the spirit of display in Honor Beacham’s heart;
but, once aroused, the intoxication of success encouraged her to proceed,
and the demon of Coquetry was found hard indeed to crush.
The row, slow and dreamy, up-stream to Teddington-lock, would, even
had there been no unlawful and much-prized lover—of whom, explain it as
you will, Honor was more than half afraid—by her side, have been simply
delightful. The river was so purely clear that the water-weeds beneath its
pellucid surface showed brightly, freshly green; and then the long low islets,
with the graceful willow-boughs, vivid with the hues of early spring,
dipping their last-opened buds into the laving stream, and the banks,
verdant and fair, and cattle-sprinkled—all combined to make a Breughal-
like picture of spring verdure and beauty.
Notwithstanding a certain amount of horsey conversation, flirting, covert
as well as open, was the order of the afternoon. Both Mrs. Foley and her
sister were adepts at that truly feminine and easily-acquired
accomplishment. To look the thing they meant not, to understand or not
understand the ingenious double entendre, to give the little hope that
hinders from despair, and only the little hope, lest the excited lover should
presume, were arts in which ces dames, the unprofessional demi-monde of
gay middle life, were thoroughly skilled. It required more audacity than
Honor would have previously believed that she possessed to cope with
rivals such as these, but, champagne aidant, she got through the female
duty well; and the dinner which succeeded the aquatic excursion owed not a
little of its success to the lively spirits lending added charms to the powerful
influence of beauty.
The hour of ten had struck by the town clocks, and the many wine-
bottles on the table of No. 3 room were near to emptying, before it occurred
to any of the party therein assembled that the night was fine and warm and
starlight, and that in the gardens of the hotel a fresher, purer air could be
imbibed than that which reminded them somewhat too forcibly of the good
things they had been imbibing.
At a conjugal hint from the Colonel, his watchful and obedient wife
suggested that the moon had risen, and was looking lovely over the river. A
turn on the terrace would be delightful, she thought; and as her proposal
met with no opposition, they made themselves an impromptu drawing-room
under the starry canopy of heaven.
“What a lovely night! how glad I am to have seen this! The moonlight
never looked to me so soft and beautiful before!”
“Never? I am glad of that,” Arthur said, his face very near to Honor’s as
they leant over the stone balustrade and gazed out upon the tranquil scene.
“I may hope then that, for a little while at least, the memory of this night
will linger with you. It is a day that I at least shall find it very hard to forget.
You smile and shake your head. Perhaps you take me for one who knows
nothing of his own mind,—one whom a fresh face can stir into new and
soon-to-be-changed feelings. But, Honor, listen to me—listen while we
have these few moments we can call our own. I tell you that the love I feel
for you is one that will defy all time and space and change. You have never
been loved, my beautiful one, with such a love as this. You would tell me,
were you not an angel, and too pure and good for such a world as this, that
your husband—”
“Hush, hush! please don’t; I cannot bear to hear you speak of him, Mr.
Vavasour,—well, well, Arthur—I know I have been very weak and wicked;
but for my own folly you would never have—have told me that you loved
me; and indeed I did not mean—I—”
He seized both her little hands in his strong grasp, and held them there as
in a vice.
“Honor,” he whispered,—and his voice trembled with concentrated
passion,—“are you going to tell me that I have been a blundering fool, and
that I have mistaken every look and word and smile that led me on to love
you? If so,—but no, I cannot, will not think it possible. Long ago, my
darling,”—and his voice softened into entreaty,—“long ago, when first I
held this precious hand in mine, you might, with cold words and scanty
smiles, have taught me”—and he smiled bitterly—“my place. But that you
did not do, Honor: you know you did not. What your motive was in leading
me on to hope that I was something—a very little—more to you than a
mere acquaintance, you best can say. If it were well meant on your part, all I
can say is that it was cruel kindness; for it will be a hard fall down again to
the place from which your gentle words and smiles had raised me. But once
more, Honor, for the love of Heaven, tell me that you have not trifled with
me. Do not make me lose my faith in every woman. Tell me before we part
to-night that if we were doomed never to meet again you would sorrow a
little, just a very little, for my loss. Tell me that sometimes, when you are
alone, you think of me; tell me”—and he ventured unreproved to steal his
arm round her waist—“tell me that you love me just a very little, Honor, in
return for the heart’s whole devotion that I feel for you.”
Her bosom heaved, and her heart beat very quickly, under the strong firm
pressure of his hand; but for all that—and perhaps some of my readers may
understand the anomaly—the strongest feeling in Honor Beacham’s mind at
that important crisis was one of relief that she was not alone with her
adorer. And yet in one sense she loved him. His touch, his lingering gaze
into the depths of her blue eyes, exercised—and never more so than at that
moment—a strange magnetic influence over her nerves. She could ill have
borne a decree that banished Arthur Vavasour from her society, and yet she
felt that he was to play no actual part in the misty future of her life—the life
which she never doubted she was to spend with John; the life that might be
a tolerably happy one when Mrs. Beacham was gathered—not to her
forefathers, but to the place allotted to her by her dead husband’s side.
Honor, to do her justice, never imagined an existence apart from her
husband. She was not happy at home; the life there was unsuited to her, and
John, she believed, did not love her well enough to care whether his mother
tormented her or not. In London, on the contrary, she did enjoy herself,
wildly, feverishly, but with a zest and an impulse that had nothing in it that
was natural or lasting. When the day came, she longed for the hour which
should bring Arthur Vavasour to her side; but with the longing came a kind
of nervous dread—a fear of his impatience, an alarm as of a hunted animal
at the thought of finding herself within his power—all which symptoms
might have told a more experienced woman that in her love for Arthur
Vavasour there was an alloy which, had he imagined its existence, would
have deprived the longing for possession of more than half its value.
It is often a misfortune to all parties concerned that the same symptoms
are indicative of various and opposite complaints. A blush is as often a sign
of innocence as of guilt; and a beating heart beneath a visibly agitated
bosom may be a token of other emotions besides the tender one of love.
When Arthur felt the throbbing pulse bounding beneath the pressure of
his hand, he never doubted that, had he been tête-à-tête with that most
peerless creature, she would have gladly sighed her love out on his breast,
listening in tender ecstasy to his vows of eternal constancy. Nearer and
nearer, happy in this blessed conviction, to his heart he held her, secured
from observation in a shadowy corner, and safe under the protection of the
remainder of the party, who lingered just out of earshot on the terrace.
Honor, afraid of offending her high-born lover, and sincerely hoping that
never—never under less safe and satisfactory circumstances might a similar
scene be enacted, contrived to stammer out the foolish, false, and guilty
assurance,—an assurance that filled the young lover’s heart with the wildest
hopes—the assurance, namely, that her heart was his, and that in his love
she found her dearest, sweetest happiness!
CHAPTER II.

A LOVER FOUND AND LOST.


“I really am at a loss to make up my mind which is the most extraordinary
—the man behaving in this way without encouragement, or your being so
lost to everything that is—ahem!—due to your position in life as to allow
him to think, to hope, that his proposals—most impertinent ones, I must say
—could meet with anything but anger and contempt.”
Lady Millicent was seated on her presidential sofa, in the room
appropriated in Bolton-square to her especial use. It was a dull, dark,
business-looking apartment. The “third drawing-room” it was called, and in
it milady was wont to receive such visitors as clearly were not there for
purposes of mere pleasure, or with the intention of ephemerally enjoying
themselves—men of law, serious men, with faces fraught with the care that
the craving after six-and-eightpences is wont to impress on the human
countenance divine, were seen entering, clearly with a purpose, the heavy
door (white-painted and gilt, but shabby and tarnished now) that led to
milady’s sanctum. It was a room into which her young daughters rarely
intruded; and when, on the morning in question (it was that of the very day
which Honor passed so feverishly with Arthur Vavasour by her side),
Rhoda, poor, timid, nervous Rhoda, was summoned to an audience with her
awe-inspiring mamma, she made her entrée with a beating heart, and,
though she knew not wherefore, with a strong presentment of evil. The open
letter in Lady Millicent’s hand was scarcely evidence enough to awaken in
her mind anything at all approaching to the truth. Rhoda was as far as the
poles from imagining that the sedate rector of Switcham, the quiet,
unpretending young man, whose “duties” ever seemed so much above his
pleasures, could have so far allowed his mundane feelings, his passions,
that were of the “earth, earthy,” to overpower his well-regulated mind, as to
induce him to offer to the great lady of Gillingham—the patroness of his
living, and one with whom he knew himself to be not a favourite—his
humble proposals for her daughter’s hand.
Standing droopingly in the august presence, and without a word to say
either in her own behalf or that of her co-delinquent, the poor girl listened
in silence to the stern and very bitter words of reprobation which fell from
her mother’s lips. Perhaps until she so listened—until she contrasted the
hard unsympathising nature of the woman to whom she owed her birth with
that of the good, thoroughly-to-be-relied-on character of the man whose
letter, with dimmed eyes and a very pitying heart, she had just contrived to
read and comprehend—she had never rightly known how necessary the
love of him, who for so many months had been her only object and point of
interest at uncongenial Gillingham, had become to her.
“I am well aware—no justly-reproachful words of yours can make me
more so” (thus one sentence of poor George’s letter ran)—“that I have no
right, in a worldly point of view, to hope that you would look otherwise
than contemptuously on my humble offer. I have little besides my deep
affection, and my prayers that God would enable me to contribute to your
beloved daughter’s happiness, to lay before one who deserves every good
gift that could be bestowed upon her. A small, very small private fortune—a
few hundreds a year only—in addition to the income derived from my
living, is all that I possess. But, if I mistake not, Miss Vavasour’s tastes are
simple ones, and she might, God aiding, be happier in the quiet home which
she would deign to share with me than in the turmoil of the great world, and
amongst the gay and rich, of whom it is said that it is hard for them to enter
the kingdom of heaven.”
“Methodistical stuff!” murmured Lady Millicent, turning over the leaves
of a law-book, and delivering herself of the severe comment on her would-
be son-in-law’s epistle at the moment when she rightly guessed that poor
Rhoda had arrived at its conclusion. “Very bad taste, I think, my dear, of
your admirer, condemning us en masse in this summary way. But now, do
tell me,” laying down the pen with which she had been making notes, “what
did you do at Gillingham to bring upon me such a letter as that? I should
have thought—but one lives and learns—that if there existed a girl in the
world who would have abstained from this kind of thing, it was you; and
now I find that—”
“O, mamma!” began poor Rhoda, whose delicacy (and she was
sensitively delicate) was severely wounded by this exordium,—“O,
mamma, I did nothing! Indeed, indeed, I gave no—I mean—I did not lead
—”
And then she stopped, poor girl, from utter inability to make herself
understood by the parent whose cold unwomanly eyes were fixed with such
unassisting scrutiny on her blushing face. There are mothers and mothers,
even as (I was about to say) there are friends and friends: but in using such
a conjunction I was wrong, for of that rare hypostasis there can be but one
variety; degrees of comparison exist not in that particular noun substantive
of the many which signify “to be, to do, and to suffer.” Either a friend’s love
passeth the love of woman, and he sticketh closer than a brother, or he is
that daily-met-with and more generally-useful thing, id est, a good-natured
acquaintance, whose services, should they not chance to interfere with his
own requirements, may possibly be at our disposal. But to return to Rhoda
Vavasour’s natural friend—to the one being who had it in her power, and
whose sacred duty it was, as far as mortal skill can do the heavenly work, to
make the crooked straight and the rough places plain to the weaker and the
tottering vessel, who was less able than herself to bear the burden and the
heat of the day. A few words softly, wisely spoken, a kind caress, the sweet
conviction, in some unknown mysterious way conveyed, that she, the
mother, was the best, the most heaven-deputed guardian for her child,
would have convinced that child, whose experience of life was nil, and who
had seen no man save her brothers whom she could compare with the right-
minded young rector of Switcham, that an engagement with that reverend
gentleman might not be exactly a desirable consummation, or one, save by
the good man himself, prudently as well as devoutly to be wished. Rhoda
was a girl thoroughly amenable to reason, as well as one whom the silken
cords of affection could have led with the lightest, tenderest touch. Delicate
of frame, physically as well as mentally, she could ill bear the wear and tear
of either excitement or worry; and perhaps George Wallingford had said no
more than the truth when he suggested that her life, in the seclusion of a
country parsonage, would probably pass more happily away than were the
nervous girl to be thrown into the whirlpool of stir and fashion, there to be
tossed to and fro amongst the vessels of iron, against which her frailer,
humbler self would be hopelessly, maybe, bruised and broken.
To convince Lady Millicent of this truth would, however, have required
eloquence far greater than that possessed by the lowly-born clergyman, who
certainly had not chosen the very likeliest way in the world to gain his ends.
As milady had truly said, there were but two ways of accounting for the
reverend gentleman’s preposterous conduct, and neither of those two ways
was calculated to throw a roseate hue over the matter. That Rhoda—her
favourite, because her most submissive, daughter—had degraded herself to
the degree of giving encouragement to “the man” for whose audacity no
words were sufficiently severe, caused as much surprise and indignation to
the magnificent widow as if she had systematically and kindly encouraged
her child to pour out into the maternal breast her cares, her sorrows, and her
joys. That a heart, young and love-requiring, will, in default of home
aliment, seek elsewhere for its natural, and in some cases even necessary,
food, this mother, engrossed by her own plans and projects for personal
aggrandisement and power, had never yet suspected. Lady Millicent—a
stay-at-home, “domestic” woman, a “widow indeed,” and one of those
constitutionally prudent matrons against whom the tongue of scandal never
had for a single instant wagged—was precisely one of those individuals
with whom self-deception is the very easiest thing in life. Her hopes and
wishes, her thoughts and fancies, never—that she could truly have said—
soared above or beyond the boundaries of her own property; and the
interests of her children, she had taught herself to believe, were the
groundwork and the motive power of all the hard, unwomanly business that
she had set herself to do.
“You are not aware, perhaps,” she said coldly to the poor girl who stood
unconsciously doubling down and plaiting with her trembling fingers the
fringe of the table-cover that hung near her,—“you are not aware, I daresay,
that, unless I succeed—for the benefit of my younger children—in a law-
suit which is in progress, your fortune, as well as Katherine’s, will be very
trifling indeed. Had your poor father lived, there would, of course, have
been an opportunity of remedying this evil, this injustice,” she added firmly,
and with a stress upon the word which poor Rhoda was far too much
engrossed by her own troubles to notice. “I tell you this, not that you may
suppose that, under any circumstances, you could have been permitted to
disgrace your family by marrying this extraordinarily presumptuous person,
but because I wish you to understand that a good marriage may be
positively necessary, both for you and for Katherine. By the way, now that
we are on this disagreeable subject, will you allow me to ask whether she—
whether your sister, who seems to me to be self-willed and forward enough
for anything—knew of this—this disgraceful entanglement: for
entanglement, Rhoda,” she went on severely, “there must have been. Poor
as my opinion naturally is of the intellect of a person who could write such
a letter as that” (pointing to it contemptuously), “quoting Scripture too in
such a personal and impertinent manner, still I cannot believe that the man
could have been such an egregious fool, could have been so preposterously
silly, as to have written to me, if you—just look at me, will you, instead of
at the carpet—had not said or done something to authorise his
presumption.”
The cold eyes fixed upon the now tearful face before her seemed to
command as well as to expect an answer. None, however, came; so, still
more authoritatively, Lady Millicent—could she find no better way of
improving her talents (id est, her children) and of showing her appreciation
of the legacy committed to her charge, than by thus torturing the feelings of
Cecil Vavasour’s young daughter?—Lady Millicent pressed the question to
which she had hitherto received none but the least comprehensible of
replies.
“Answer me. Really I have no more time to waste. Had you any idea that
this Mr. Wallingford intended making the application which strikes me as so
extraordinary?”
With some difficulty, Rhoda managed to stammer forth a negative.
“Indeed no,” she said; “and, mamma, Kate knew no more about it than I
did. I never told her—I mean, I—”
She stopped suddenly, her face the colour of the setting sun when,
“cradled in vermilion,” it throws its red reflection over slope and mountain,
land and river. On her cheek and brow and slender neck the tell-tale witness
rushed; and Lady Millicent—well aware that her guileless daughter knew
and felt that she had committed herself—said, even more coldly than
before:
“You are a poor dissembler, Rhoda. You may go to your room now. Of
course you allowed this man, this hypocritical good clergyman, to lead you
into deception. You let him fancy—for it is only fancy on your part—that
—”
“O mamma,—dear mamma,” the girl cried in an agony of shame and
grief, “if you would only listen to me,—only believe that I never did, never
could have done all you say! I wish I could tell you how it was; and yet it
seems—indeed it does—as if I had nothing—nothing really to tell. We used
to meet—Mr. Wallingford and I—sometimes at the school, and at the poor
people’s cottages. He is so good, mamma,” gaining a little courage when
she found herself listened to without rebuke. “If you could but know how
much the sick and the old think of him, and all he does for them, you would
not wonder at—”
“At his doing one of the most unprincipled acts of which a man can be
capable,” sneered Lady Millicent. “He was perfectly well aware—he says
so in his letter—that I should be intensely angry at his presumption; and yet
—really, Rhoda, I have no patience with your folly and wrongheadedness—
you stand up for this priggish, formal, underhand—”
“But he has not been underhand, mamma. As Mr. Wallingford is not here
to tell you so himself, I must say the truth; and that is, that never till the day
before we left Gillingham did he say one word that you might not have
heard, and then he only”—and the colour deepened on her cheek—“said
that he should miss me—should think of me till I came back, and that he
hoped I would not quite forget Gillingham and—and ‘good things’ while I
was away.”
Lady Millicent laughed scornfully.
“For Gillingham read Mr. Wallingford, and for good things the delights,
I suppose, of Switcham Parsonage,—boiled leg of mutton and what is
called, I believe, a parlour-maid to wait upon you. My dear Rhoda, be
thankful that such a fate as becoming the wife of a poor country parson is
not in store for you. And now, my dear, you may go, as I said before, to
your own room. There is no occasion to make this sort of thing public. I
shall of course answer Mr. Wallingford’s letter, and I think I may venture to
say that we are not likely to be troubled further on the subject. There, there,
that will do; I am very much engaged this morning,”—arresting the words
which she could see were hovering on her daughter’s lips,—“and I can
afford to waste no more time on such nonsense as this.”
The head and eyes resolutely bent upon the folio before her, the decided
tone of a voice whose stern, determined accents Rhoda knew and
understood full well, convinced the timid girl that appeal there was none,
and that nothing remained for her but to obey. With a heavy heart she
ascended the stairs to the chamber that she called her own, and which,
opening into a smaller one appropriated to Kate, enabled that lighter-
spirited young lady to overhear through the keyhole of the door the hardly
suppressed sobs which broke from the breast of the unhappy Rhoda.
“My darling, what is the matter?” cried the younger girl, rushing in
impetuously,—for Kate’s strong points were certainly neither prudence nor
self-control,—“what is the matter, you poor dear?” And tumbling on her
knees by the side of her weeping sister, Kate began sobbing too by sheer
force of sympathy.
A very few words sufficed to put the latter au fait of the secret—secret,
alas, no longer—which Rhoda had so long and so sedulously kept. Kate
listened with eager ears and widely-distended eyes to the details, stammered
forth incoherently, of this first love episode in the family. As a love affair, it
was certainly not without its interest; but with that interest, and in spite of
her sisterly compassion, Katie certainly did feel a little surprise at the
singularity of Rhoda’s choice. She made no allowance for the utter absence
of competitors for her sister’s favour; all that was patent to this damsel of
fast proclivities—who thought Sunday-schools a bore, and who hoped some
day to be wooed by a lover of a widely different type—was the fact that Mr.
Wallingford had straight hair, was anything but “jolly,” had the misfortune
to possess scanty whiskers, did not smoke, and, to sum up all his defects in
one comprehensive word, was a “parson.”
“I can’t the least understand how Rhoda can care for him,” she said an
hour afterwards to her eldest brother, to whom she had just narrated the
provoking circumstance that her sister, who was in love with that stupid Mr.
Wallingford, had cried so long and so bitterly that she wasn’t fit to be seen,
—“a man who is always talking ‘good,’ and who, of course, thinks it’s
wicked to be jolly. Can you make it out, Arthur? I suppose it was all done
by staring at each other, for I never saw them speaking, or seeming as if
anything was going on.”
“Of course you didn’t,” her brother said, as he settled his cravat in the
pier-glass over the mantelshelf (he was going to ride—his usual morning
avocation—with Honor Beacham, and naturally wished to look his best on
the occasion),—“of course you didn’t. Girls when they are in love (and the
best girls too) will deceive even other women,—a very different affair, I can
tell you, from taking in a man; and if you think, my dear Katie—”
“O don’t bother about that now,” Kate said impatiently. “I asked you
whether you can believe that Rhoda really likes Mr. Wallingford. I can’t
fancy his being a lover: horrid creature, I call him! Now, Arthur, do attend
one moment. I want to know whether I ought to be glad or sorry that
mamma has put an end to the business, and—”
“Glad, to be sure,” said Arthur, taking up his gloves, and troubling
himself less than was altogether brotherly about poor Rhoda’s first and, as
the preoccupied young man considered, thoroughly uninteresting love-
affair,—“glad! Why it’s the most disgusting piece of folly I ever heard of.
Such bad taste too! But it’s all my mother’s fault. If a gushing young
woman like Rhoda had seen some good-looking young fellows every now
and then, she would never have got spooney on such a slow prig of a parson
as George Wallingford. An excellent young man, I daresay, in his way; but
excellent young men haven’t much of a pull in these days, except when
girls haven’t anyone else to talk to. Trust me, it won’t be long, if I know
anything about such matters, before Miss Rhoda finds another lover ready
to knock this spooney fellow out of her head.” And Arthur Vavasour,
satisfied with this summary settlement of a question which probably
appeared to him in the light of a very commonplace affair indeed, hurried
away to his appointment in Stanwick-street—hurried to the presence of the
still pure-hearted woman, for the love of whose bright eyes the silly young
man was ready to lose his all of peace on earth, the goodwill of friends and
kindred, and that much-prized but unexplainable thing for which no other
nation save our own can boast even the simple name—the name, that is, of
Respectability.
CHAPTER III.

WHAT WAS HONOR DOING?


It was Sunday at the Paddocks,—Sunday afternoon,—rather a ponderous
season in the old silent house; and John was, sooth to say, a trifle tired of
his own thoughts, to say nothing of the sight of his respectable parent
poring, spectacles on nose, over the heavy sermon (a Sabbath duty with her,
and a habit which she was far too old to break), that kept her in a blissful
doze through two hours at least of that long afternoon of rest.
The early dinner was over; and the house being very quiet—no sound
more startling than the buzz of the flies upon the window-pane breaking the
stillness of the restful time—John Beacham, who had ensconced himself in
his big arm-chair, feeling dull enough, poor fellow, without Honor, began to
experience not only the influence of the heat but of the Sabbath beef and
pudding; and his eyelids, “drawing straws,” as the saying is, closed
gradually over the tranquil scenes before him, and the deserted husband
found himself in the land of dreams.
How long he had slept he knew not, when he was roused by a man’s step
in the entrance-hall near him, and by a voice which in the first
bewilderment of waking he failed to recognise as that of Jack Winthrop, the
owner of the wicked chestnut, and a distant neighbour, whose visits, few
and far between, were usually paid on that dies non to a business man, a
Sunday afternoon.
“Hallo, old fellow! taking a snooze, eh?” was Jack’s jovial greeting; and
then the two men shook hands, while Mrs. Beacham, adjusting her
spectacles, and with rather a scared look in her sharp old eyes, endeavoured,
under the appearance of being still more wideawake than usual, to hide the
fact that she had been asleep.
Jack was not much—as he often remarked himself—of a ladies’ man. He
was far more at home in the stable than the drawing-room. Nevertheless,
and especially when he had on his go-to-meeting coat and hat, he could
shuffle through the usual forms of social good breeding with tolerable
success. Of these forms, a short dissertation on the weather, past, present,
and to come, together with a few polite inquiries regarding the health and
whereabouts of the members of their respective families, stood first in
importance. It was to the last of these conversational duties that Mrs.
Beacham was indebted for some valuable information regarding the
proceedings of the erratic young woman whose continued absence was to
the old lady a perpetual source of mingled anger and satisfaction.
“Well, and how do you get along without the missus; eh, John?” asked
the visitor. And then, with a rather meaning wink and a jerk of his
smoothly-brushed yellow head, “I expect I’ve seen Mrs. John since you
have; caught sight of her yesterday morning as I was tooling through the
Park. She was a-horseback, looking like paint,—so she was, with such a
colour,—and the young Squire along with her. There was a servant behind
’em on a screwed bay horse; and I didn’t think much of the one the missus
rode either—a leggy brute! She wouldn’t think much of him, I fancy, after
Lady Meg. But you’ll have her—the missus, I mean—back again soon, I
doubt.” And the worthy, stupid fellow—stupid, that is, in everything but
what regarded horse-flesh—pulled up at last, entirely unconscious that he
had applied the match to a train, and that a “blowing-up” of some kind or
other would be the inevitable consequence of his thoughtlessly-spoken
words.
It was not till some hours later, and when Jack—who had been walked
over every acre of the Paddocks, and been encouraged to linger longer than
visitor had ever lingered before in each loose box and stall—that John
Beacham and his mother, each in their several elbow-chairs, consumed their
meal of herbs—id est, their tea and bread-and-butter—in silence and in
gloom. John had delayed, with a cowardice very unusual to his open,
natural, fearless character, the moment, dreaded beyond any previous
moment of his life,—that, namely, when Honor’s conduct, her duplicity, her
shamelessness, and worst of all, her dislike to him and to her home, would
infallibly come under discussion between himself and his mother. To
describe John’s sensations during the revelations of Mr. Winthrop would be
impossible. To hear that his Honor,—the fair young wife whom he had
pictured to himself living a secluded life in her father’s dull and poverty-
stricken home,—to hear, I say, from authority undeniable, that she was
recreating herself with horse exercise in the Lady’s Mile with a young
gentleman,—the young gentleman of whose designs, or rather the report of
whose designs, upon his wife’s affections, Mrs. Beacham had already more
than once irritated him by hinting at,—was to receive a stab sharp and cruel,
as it was wholly unexpected, in the warm honest heart that still contained
within it such a wealth of love for the backsliding absent one. He had made
no sign—it was his way (a misfortune in some cases) to make no sign till
such time as the gathering stream of passion, defying all control, burst
through its bonds, and spent itself in outward fury—he made no sign of
what he was enduring whilst Honor’s sin of suppressio veri (to use the
mildest term) was shown up in glaring colours by his officious visitor. From
his manner—but then Jack was not an observant character,—that sporting
individual would never have imagined that his old friend was undergoing
torture very difficult to endure with outward composure; and that John
Beacham did so endure it was partly owing to his dread that the old lady,
who was not famous for concealing what she called her “feelings,” might,
by an outburst of indignation, betray the mortifying fact that his young wife
was wronging and deceiving him. That such a manifestation was to the last
degree unadvisable was so clearly and intentionally demonstrated by John’s
demeanour, that Mrs. Beacham, though sorely against her will, limited the
expression of her wrath to an “Ah, well!” followed by the compressed lips
which so often betray that wrath “to be kept warm” is being nursed within
the breast.
It was with curiously different feelings that the mother and son awaited
the time when Honor’s conduct, as revealed by Jack Winthrop, should be in
solemn conclave sat in judgment on, and, as a matter of course, condemned.
For that time—for the auspicious moment when John should have returned
from that interminable walk, when his Brother farmer, “drat him” (I am
afraid that, Sunday though it was, the worthy old lady did indulge in a mild
imprecation or two on the head of her unconscious visitor), should have
taken his departure, and when they two should be sitting comfortably (?)
over their tea, Mrs. Beacham longed with a feverish and impatient craving.
It was so hard, so very hard upon her, that she was perforce obliged to keep
this weighty discovery within the limits of her own breast. A secret, like a
very young man’s forbidden love affair, is worth nothing unless you can
divulge it to the one friend who promises with such solemn vows to keep it
closely (as closely, poor confiding one, as you have done yourself); and had
the widow Thwaytes chanced to “drop in” that Sunday afternoon—a step
which that scandal-lover would infallibly have taken could the remotest
surmise of the delightful existing field for gossip have reached her ears—
the delinquencies of the absent Honor would very soon have become public
property at Switcham. Such luck, however, as a visit from her congenial
humble friend was not, on that day at least, in store for the busy irate old
woman, who, strong in the strength of her Sabbath silk gown and great in
her conscious dignity of mistress regent at the Paddocks, sat prepared to
make—certainly not the best of her young daughter-in-law’s shortcomings.
“Well, John, what do you think of this?” was her startling exordium
when Hannah had left the room, and John—poor John—had no escape, and
no longer even a reprieve from listening to abuse—abuse, it was to be
feared, only too well merited—of his beloved one. “Well, John, this looks
nice, doesn’t it? So milady stays in Lunnon, not to nurse her father, as she’d
have us believe, but to go tearing about Hyde Park with Mr. Vavasour!
Pretty doings, upon my word! I declare to goodness, if you take no notice of
this, I shall think you’re just gone clean out of your mind, and are only fit
for an asylum, so you are.”
She stopped, more from lack of breath to proceed than from any
immediate prospect that appeared of John’s responding to her attack. He felt
called upon, however, to make some reply to what sounded like an implied
accusation of lukewarmness, and of a disposition to “take things” far more
easily than he was in the humour to do. His mother’s abrupt onslaught had,
however, already produced an effect directly contrary to what the indignant
old lady had intended. She had either forgotten or ignored the sensible
proverb which saith “Scald not thy lips in another man’s porridge,” and had
aroused in her son that fraction of masculine dignity which causes its
possessor to resist interference in the management of his house and harem.
Besides, John’s love for the beautiful object of Mrs. Beacham’s jealousy
was still far too strong for him to endure patiently the hearing his wife
found fault with by any other than himself; and this being the case, his reply
did not greatly tend to Mrs. Beacham’s satisfaction.
“Jack Winthrop is a chattering fool. I daresay he mistook Honor for
someone else, for one of young Vavasour’s sisters probably; and even if she
was riding in the Park, where’s the mighty harm? It was but yesterday he
saw her—says he saw her, at least—and it’s quite time enough to pull her
up if she says nothing of it herself next time she writes, which will be to-
morrow if I’m not mistaken.” And John, having so said, pushed back his
chair with the evident intention of closing the conference. His mother,
however, was not to be thus cheated of her treat. She had not been waiting
for six mortal hours to be put off with such a stupid shuffle as that! No! For
once in his life John should hear reason, let what would come of it, and if
there was no one else to tell him the truth, his mother would do her duty,
and point out to the infatuated man what, in this crisis of his fate, was his!
“John, John!” she said, lifting up a stubborn finger warningly; “if I
hadn’t heerd and seen this myself, I never could—and that’s the truth—have
believed it. To think that you, a man grown and with a man’s blood in your
veins, should let a woman lead you by the nose like this!”
“Nonsense, mother!” with an unsuccessful effort to laugh the matter off.
“No one is leading me, or thinking of leading me, by the nose, as you call it.
Honor is a silly girl, I don’t say she isn’t, and she’s fond of a horse; and if
her father—gad! how I hate to speak of the fellow!—if her father put it into
her foolish head to ride, why ride she would, nor I don’t blame her neither.
So, mother, let you and I hear the rights of it before we blame her; and
what’s more—you’ll forgive my speaking”—approaching nearer, and his
breath coming shorter as he spoke—“but if you would remember, mother
dear, not to speak to anyone in the village about this—story—of Honor and
the—the Park, I should esteem it very kind, and—”
“Oh, my dear, you may make yourself quite easy,” snorted the old lady.
“I’m not the bird to defile my own nest. It won’t be through me if disgrace
comes upon the family, and if you like to encourage your wife in her goings
on with gentlemen—”
“Come, come, mother,” broke in her son; “I must not have my wife
spoken of, before she deserves it, as if she was a—a gay woman. I beg your
pardon, but you make me more angry than I ought to be; and it isn’t right,
mother, God’s book says it ain’t. ‘Blessed are the peacemakers,’ we are told,
and grievous words only stir up anger, they do; so let’s keep from ’em while
we can. I’m expecting to hear from Honor to-morrow, and if she says she’s
coming home and writes about this foolish ride of hers, why we shall be
sorry then, poor pretty creature, that we said a word against her.” And John,
perfectly unconscious of the strangely mixed feelings, the half fear—a
dread unadmitted even to his own breast—that Honor both deserved and
would be visited with punishment, wished his mother “good-night,” and left
her to her reflections.

You might also like