0% found this document useful (0 votes)
4 views

Microsoft Visual C 2010 An Introduction to Object Oriented Programming 4th Edition Joyce Farrell pdf download

The document provides information about the book 'Microsoft Visual C# 2010: An Introduction to Object-Oriented Programming' by Joyce Farrell, including its availability for download in various formats. It outlines the contents of the book, which covers fundamental programming concepts using C#, and includes chapters on data usage, decision-making, and object-oriented programming principles. Additionally, it mentions other related educational resources and textbooks available for purchase.

Uploaded by

syiaedoka
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views

Microsoft Visual C 2010 An Introduction to Object Oriented Programming 4th Edition Joyce Farrell pdf download

The document provides information about the book 'Microsoft Visual C# 2010: An Introduction to Object-Oriented Programming' by Joyce Farrell, including its availability for download in various formats. It outlines the contents of the book, which covers fundamental programming concepts using C#, and includes chapters on data usage, decision-making, and object-oriented programming principles. Additionally, it mentions other related educational resources and textbooks available for purchase.

Uploaded by

syiaedoka
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 65

Microsoft Visual C 2010 An Introduction to

Object Oriented Programming 4th Edition Joyce


Farrell pdf download

https://ebookname.com/product/microsoft-visual-c-2010-an-
introduction-to-object-oriented-programming-4th-edition-joyce-
farrell/

Get Instant Ebook Downloads – Browse at https://ebookname.com


Instant digital products (PDF, ePub, MOBI) available
Download now and explore formats that suit you...

Object Oriented Programming Using C Fourth Edition


Joyce Farrell

https://ebookname.com/product/object-oriented-programming-using-
c-fourth-edition-joyce-farrell/

Introduction to Object Oriented Programming An 3rd


Edition Timothy Budd

https://ebookname.com/product/introduction-to-object-oriented-
programming-an-3rd-edition-timothy-budd/

Object Oriented Programming With C 4th Edition E.


Balagurusamy

https://ebookname.com/product/object-oriented-programming-
with-c-4th-edition-e-balagurusamy/

Ophthalmic Drug Delivery Systems Second Edition Drugs


and the Pharmaceutical Sciences a Series of Textbooks
and Monographs Ashim Mitra

https://ebookname.com/product/ophthalmic-drug-delivery-systems-
second-edition-drugs-and-the-pharmaceutical-sciences-a-series-of-
textbooks-and-monographs-ashim-mitra/
Exam Preparation and Practice Guide Mathematical
Studies SL 1st Edition Mal Coad

https://ebookname.com/product/exam-preparation-and-practice-
guide-mathematical-studies-sl-1st-edition-mal-coad/

Double Vision A Journey to Success 1st Edition Wayne


Caines

https://ebookname.com/product/double-vision-a-journey-to-
success-1st-edition-wayne-caines/

Penumbra The Premier Stage for African American Drama


1st Edition Macelle Mahala

https://ebookname.com/product/penumbra-the-premier-stage-for-
african-american-drama-1st-edition-macelle-mahala/

Assessment In Special and Inclusive Education Eleventh


Edition John Salvia

https://ebookname.com/product/assessment-in-special-and-
inclusive-education-eleventh-edition-john-salvia/

Briefs of Leading Cases in Corrections Fifth Edition


Rolando V. Del Carmen

https://ebookname.com/product/briefs-of-leading-cases-in-
corrections-fifth-edition-rolando-v-del-carmen/
The Girl on the Magazine Cover The Origins of Visual
Stereotypes in American Mass Media Carolyn L. Kitch

https://ebookname.com/product/the-girl-on-the-magazine-cover-the-
origins-of-visual-stereotypes-in-american-mass-media-carolyn-l-
kitch/
Apago PDF Enhancer
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
Apago PDF Enhancer
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.
FOURTH EDITION

MICROSOFT®
VISUAL C#® 2010
AN INTRODUCTION TO OBJECT-ORIENTED PROGRAMMING

Apago PDF Enhancer

J O Y C E FA R R E L L

Australia • Brazil • Japan • Korea • Mexico • Singapore • Spain • United Kingdom • United States
Microsoft® Visual C#® 2010: An © 2011 Course Technology, Cengage Learning
Introduction to Object-Oriented
ALL RIGHTS RESERVED. No part of this work covered by the copyright
Programming, Fourth Edition
herein may be reproduced, transmitted, stored, or used in any form or by
Joyce Farrell any means—graphic, electronic, or mechanical, including but not limited
to photocopying, recording, scanning, digitizing, taping, Web distribution,
Publisher: Nicole Pinard
information networks, or information storage and retrieval systems, except
Executive Editor: Marie Lee as permitted under Section 107 or 108 of the 1976 United States Copyright
Acquisitions Editor: Amy Jollymore Act—without the prior written permission of the publisher.

Senior Product Manager: Alyssa Pratt


Development Editor: Dan Seiter For product information and technology assistance, contact us at
Cengage Learning Customer & Sales Support, 1-800-354-9706
Content Project Manager: Lisa Weidenfeld
For permission to use material from this text or product,
Manufacturing Buyer: Julio Esperas submit all requests online at www.cengage.com/permissions
Proofreader: Brandy Lilly Further permissions questions can be e-mailed to
[email protected]
Copyeditor: Michael Beckett
Indexer: Sharon Hilgenberg
Library of Congress Control Number: 2010930061
Art Director: Faith Brosnan
ISBN-13: 978-0-538-47951-6
Text Designer: Shawn Girsberger
ISBN-10: 0-538-47951-5
Cover Photo: iStockphoto.com/Dimitrije
Course Technology
Cover Designer: Bruce Bond 20 Channel Center Street
Editorial Assistant: Jacqueline Lacaire Boston, MA 02210
Art Director: Marissa Falco USA

Marketing Manager: Adam Marsh Apago Cengage


PDF Enhancer
Learning is a leading provider of customized learning solutions
with office locations around the globe, including Singapore, the United
Quality Assurance: Chris Scriver and Kingdom, Australia, Mexico, Brazil, and Japan. Locate your local office at:
Danielle Shaw www.cengage.com/global
Compositor: Integra Cengage Learning products are represented in Canada by
Nelson Education, Ltd.
To learn more about Course Technology, visit www.cengage.com/
coursetechnology
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
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 people, 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
people or companies.
Course Technology, a part of 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.

Printed in the United States of America


1 2 3 4 5 6 7 14 13 12 11 10
Brief Contents
iii

Pref ace . . . . . . . . . . . . . . . . . xv
CH AP TER 1 A F ir s t Prog ram Usi ng C# . . . . . . . . . 1
CH AP TER 2 U s in g Dat a . . . . . . . . . . . . . . . . 49
CH AP TER 3 U s in g GU I Obj ec ts and the V i sual
St u dio IDE . . . . . . . . . . . . . . . 103
CH AP TER 4 M ak in g Deci si o ns . . . . . . . . . . . . 142
CH AP TER 5 Lo o pin g . . . . . . . . . . . . . . . . 194
CH AP TER 6 U s in g Ar r a y s . . . . . . . . . . . . . . 232
CH AP TER 7 UApago
s in g M ethoPDF
ds . Enhancer
. . . . . . . . . . . . 273
CH AP TER 8 Advan ced Met ho d Concepts . . . . . . . . 315
CH AP TER 9 U s in g Clas ses a nd Obj ects . . . . . . . . 354
CH AP TER 10 In t ro du ct io n t o I nheri tance . . . . . . . . 427
CH AP TER 11 Except io n Hand l i ng . . . . . . . . . . . 490
CH AP TER 12 U s in g Co n t ro l s . . . . . . . . . . . . . 540
CH AP TER 13 H an dlin g E v ent s . . . . . . . . . . . . . 606
CH AP TER 14 F iles an d St ream s . . . . . . . . . . . . 656
CH AP TER 15 U s in g LINQ t o A ccess Data i n C#
Pro g r am s . . . . . . . . . . . . . . . . 708
BRIEF CONTENTS

AP PEN DIX A Oper at o r Pre cede nce And Associ ati v i ty . . . 764
AP PEN DIX B U n der s t an ding Numberi ng Sy stems
an d Co m pu t er Co des . . . . . . . . . . . 766
AP PEN DIX C U s in g T h e IDE E d i tor . . . . . . . . . . . 775
iv
Glo s s ar y . . . . . . . . . . . . . . . . 779
In dex . . . . . . . . . . . . . . . . . 799

Apago PDF Enhancer


Contents
v

Pref ace . . . . . . . . . . . . . . . . . xv

C HAP TER 1 A F ir s t Prog ram Usi ng C# . . . . . . . . . 1


Programming . . . . . . . . . . . . . . . . . . . . . . . 2
Procedural and Object-Oriented Programming . . . . . . . . 4
Features of Object-Oriented Programming Languages . . . . . 7
The C# Programming Language . . . . . . . . . . . . . . . 9
Writing a C# Program That Produces Output . . . . . . . . . 10
Selecting Identifiers . . . . . . . . . . . . . . . . . . . . 14
Improving Programs by Adding Comments and
Using the System Namespace . . . . . . . . . . . . . . 18
Adding Program Comments . . . . . . . . . . . . . . . . 18
Apago PDF Enhancer
Using the System Namespace . . . . . . . . . . . . . . 19
Writing and Compiling a C# Program . . . . . . . . . . . . 21
Compiling Code from the Command Prompt . . . . . . . . 21
Compiling Code within the Visual Studio IDE . . . . . . . . 24
You Do It . . . . . . . . . . . . . . . . . . . . . . . . . 26
Entering a Program into an Editor . . . . . . . . . . . . . 26
Compiling and Executing a Program from the
Command Line . . . . . . . . . . . . . . . . . . . . . 27
Compiling and Executing a Program Using
the Visual Studio IDE . . . . . . . . . . . . . . . . . . 29
Deciding Which Method to Use . . . . . . . . . . . . . . 35
Adding Comments to a Program . . . . . . . . . . . . . . 36
Chapter Summary . . . . . . . . . . . . . . . . . . . . . 37
Key Terms . . . . . . . . . . . . . . . . . . . . . . . . 38
Review Questions . . . . . . . . . . . . . . . . . . . . . 42
Exercises . . . . . . . . . . . . . . . . . . . . . . . . . 46

C HAP TER 2 U s in g Dat a . . . . . . . . . . . . . . . . 49


Declaring Variables . . . . . . . . . . . . . . . . . . . . 50
Displaying Variable Values . . . . . . . . . . . . . . . . . 54
CONTENTS

Using the Integral Data Types . . . . . . . . . . . . . . . . 58


Using Floating-Point Data Types . . . . . . . . . . . . . . . 60
Formatting Floating-Point Values . . . . . . . . . . . . . . 61
Using Arithmetic Operators . . . . . . . . . . . . . . . . . 63
Using Shortcut Arithmetic Operators . . . . . . . . . . . . 65
vi
Using the bool Data Type . . . . . . . . . . . . . . . . . 67
Understanding Numeric Type Conversion . . . . . . . . . . . 68
Using the char Data Type . . . . . . . . . . . . . . . . . 71
Using the string Data Type . . . . . . . . . . . . . . . . 73
Defining Named Constants . . . . . . . . . . . . . . . . . 77
Working with Enumerations . . . . . . . . . . . . . . . . 78
Accepting Console Input . . . . . . . . . . . . . . . . . . 80
You Do It . . . . . . . . . . . . . . . . . . . . . . . . . 82
Declaring and Using Variables . . . . . . . . . . . . . . . 82
Performing Arithmetic . . . . . . . . . . . . . . . . . . 84
Working with Boolean Variables . . . . . . . . . . . . . . 85
Using Escape Sequences . . . . . . . . . . . . . . . . . 86
Writing a Program that Accepts User Input . . . . . . . . . 87
Chapter Summary . . . . . . . . . . . . . . . . . . . . . 88
Key Terms . . . . . . . . . . . . . . . . . . . . . . . . 89
Review Questions . . . . . . . . . . . . . . . . . . . . . 93
Apago PDF Enhancer
Exercises . . . . . . . . . . . . . . . . . . . . . . . . . 97

C HAP TER 3 U s in g GU I Obj ect s and the V i sual


St u dio IDE . . . . . . . . . . . . . . . 103
Creating a Form in the IDE . . . . . . . . . . . . . . . . 104
Using the Toolbox to Add a Button to a Form . . . . . . . 109
Adding Functionality to a Button on a Form . . . . . . . 111
Adding Labels and TextBoxes to a Form . . . . . . . . 114
Formatting Data in GUI Applications . . . . . . . . . . . 119
Naming Forms and Controls . . . . . . . . . . . . . . . 119
Correcting Errors . . . . . . . . . . . . . . . . . . . . 121
Deleting an Unwanted Event-Handling Method . . . . . . . 123
Failing to Close a Form Before Attempting
to Reexecute a Program . . . . . . . . . . . . . . . 124
Using Visual Studio Help . . . . . . . . . . . . . . . . 124
Deciding Which Interface to Use . . . . . . . . . . . . . 125
You Do It . . . . . . . . . . . . . . . . . . . . . . . . 127
Working With the Visual Studio IDE . . . . . . . . . . . 127
Providing Functionality for a Button . . . . . . . . . . 131
Adding a Second Button to a Form . . . . . . . . . . 132
Chapter Summary . . . . . . . . . . . . . . . . . . . . 133
Key Terms . . . . . . . . . . . . . . . . . . . . . . . 134
CONTENTS

Review Questions . . . . . . . . . . . . . . . . . . . . 135


Exercises . . . . . . . . . . . . . . . . . . . . . . . . 139

C HAP TER 4 M ak in g Deci si o ns . . . . . . . . . . . . 142


Understanding Logic-Planning Tools
vii
and Decision Making . . . . . . . . . . . . . . . . . . 143
Making Decisions Using the if Statement . . . . . . . . . 146
A Note on Equivalency Comparisons . . . . . . . . . . . 152
Making Decisions Using the if-else Statement . . . . . . 152
Using Compound Expressions in if Statements . . . . . . 155
Using the Conditional AND Operator . . . . . . . . . . . 156
Using the Conditional OR Operator. . . . . . . . . . . . 157
Using the Logical AND and OR Operators. . . . . . . . . 158
Combining AND and OR Operators . . . . . . . . . . . . 159
Making Decisions Using the switch Statement . . . . . . 161
Using an Enumeration with a switch Statement . . . . . 165
Using the Conditional Operator . . . . . . . . . . . . . . 166
Using the NOT Operator . . . . . . . . . . . . . . . . . 167
Avoiding Common Errors When Making Decisions . . . . . . 169
Performing Accurate and Efficient Range Checks . . . . . 169
Apago PDF Enhancer
Using && and || Appropriately . . . . . . . . . . . . . 171
Using the ! Operator Correctly . . . . . . . . . . . . . 171
Decision-Making Issues in GUI Programs . . . . . . . . . . 173
You Do It . . . . . . . . . . . . . . . . . . . . . . . . 175
Using if-else Statements . . . . . . . . . . . . . . 175
Using AND and OR Logic . . . . . . . . . . . . . . . . 177
Chapter Summary . . . . . . . . . . . . . . . . . . . . 179
Key Terms . . . . . . . . . . . . . . . . . . . . . . . 181
Review Questions . . . . . . . . . . . . . . . . . . . . 183
Exercises . . . . . . . . . . . . . . . . . . . . . . . . 188

C HAP TER 5 Lo o pin g . . . . . . . . . . . . . . . . 194


Using the while Loop . . . . . . . . . . . . . . . . . . 195
Using the for Loop . . . . . . . . . . . . . . . . . . . 201
Using the do Loop . . . . . . . . . . . . . . . . . . . . 204
Using Nested Loops . . . . . . . . . . . . . . . . . . . 207
Accumulating Totals . . . . . . . . . . . . . . . . . . . 210
Improving Loop Performance . . . . . . . . . . . . . . . 213
Looping Issues in GUI Programs. . . . . . . . . . . . . . 214
You Do It . . . . . . . . . . . . . . . . . . . . . . . . 217
Using a while Loop . . . . . . . . . . . . . . . . . . 217
Using for Loops . . . . . . . . . . . . . . . . . . . 218
CONTENTS

Chapter Summary . . . . . . . . . . . . . . . . . . . . 221


Key Terms . . . . . . . . . . . . . . . . . . . . . . . 222
Review Questions . . . . . . . . . . . . . . . . . . . . 223
Exercises . . . . . . . . . . . . . . . . . . . . . . . . 227

viii C HAP TER 6 U s in g Ar r ays . . . . . . . . . . . . . . 232


Declaring an Array and Assigning Values
to Array Elements . . . . . . . . . . . . . . . . . . . 233
Initializing an Array . . . . . . . . . . . . . . . . . . . 235
Accessing Array Elements . . . . . . . . . . . . . . . . 237
Using the Length Property. . . . . . . . . . . . . . . 237
Using foreach . . . . . . . . . . . . . . . . . . . . 238
Using foreach with Enumerations . . . . . . . . . . . 239
Searching an Array Using a Loop . . . . . . . . . . . . . 240
Using a for Loop to Search an Array . . . . . . . . . . 241
Using a while Loop to Search an Array . . . . . . . . . 243
Searching an Array for a Range Match . . . . . . . . . . 245
Using the BinarySearch(), Sort(),
and Reverse() Methods . . . . . . . . . . . . . . . 247
Using the BinarySearch() Method . . . . . . . . . . 247
Using the Sort() Method . . . . . . . . . . . . . . . 249
Apago PDF Enhancer
Using the Reverse() Method . . . . . . . . . . . . . 250
Using Multidimensional Arrays . . . . . . . . . . . . . . 252
Array Issues In GUI Programs . . . . . . . . . . . . . . . 257
You Do It . . . . . . . . . . . . . . . . . . . . . . . . 259
Creating and Using an Array . . . . . . . . . . . . . . 259
Using the Sort() and Reverse() Methods . . . . . . 260
Chapter Summary . . . . . . . . . . . . . . . . . . . . 261
Key Terms . . . . . . . . . . . . . . . . . . . . . . . 263
Review Questions . . . . . . . . . . . . . . . . . . . . 264
Exercises . . . . . . . . . . . . . . . . . . . . . . . . 268

C HAP TER 7 U s in g M et h o ds . . . . . . . . . . . . . 273


Understanding Methods and Implementation Hiding . . . . . 274
Understanding Implementation Hiding . . . . . . . . . . 275
Writing Methods with No Parameters
and No Return Value . . . . . . . . . . . . . . . . . . 276
Understanding Accessibility . . . . . . . . . . . . . . . 277
Understanding the Optional static Modifier . . . . . . . 278
Understanding the Return Type . . . . . . . . . . . . . 278
Understanding the Method Identifier . . . . . . . . . . . 279
Creating a Simple Method . . . . . . . . . . . . . . . 279
CONTENTS

Writing Methods That Require a Single Argument . . . . . . 281


Writing Methods That Require Multiple Arguments . . . . . . 285
Writing a Method That Returns a Value . . . . . . . . . . . 287
Writing a Method that Returns a Boolean Value . . . . . . 289
Passing an Array to a Method . . . . . . . . . . . . . . . 290
Alternate Ways to Write a Main() Method Header . . . . . 295 ix
Issues Using Methods in GUI Programs . . . . . . . . . . 297
Understanding Methods that are Automatically
Generated in the Visual Environment . . . . . . . . . . 297
Appreciating Scope in A GUI Program . . . . . . . . . . 298
Creating Methods to be Nonstatic when Associated
with a Form . . . . . . . . . . . . . . . . . . . . . 298
You Do It . . . . . . . . . . . . . . . . . . . . . . . . 299
Calling a Method . . . . . . . . . . . . . . . . . . . . 299
Writing a Method that Receives Parameters
and Returns a Value . . . . . . . . . . . . . . . . . 300
Chapter Summary . . . . . . . . . . . . . . . . . . . . 302
Key Terms . . . . . . . . . . . . . . . . . . . . . . . 303
Review Questions . . . . . . . . . . . . . . . . . . . . 305
Exercises . . . . . . . . . . . . . . . . . . . . . . . . 309

C HAP TER 8
Apago PDF Enhancer
Advan ced Met ho d Concepts . . . . . . . . 315
Understanding Parameter Types. . . . . . . . . . . . . . 316
Using Mandatory Value Parameters . . . . . . . . . . . 316
Using Reference and Output Parameters . . . . . . . . . 318
Using Parameter Arrays . . . . . . . . . . . . . . . . 321
Overloading Methods. . . . . . . . . . . . . . . . . . . 323
Understanding Overload Resolution . . . . . . . . . . . 329
Understanding Built-In Overloaded Methods . . . . . . . . 330
Avoiding Ambiguous Methods . . . . . . . . . . . . . . . 332
Using Optional Parameters . . . . . . . . . . . . . . . . 334
Leaving Out Unnamed Arguments . . . . . . . . . . . . 336
Using Named Arguments . . . . . . . . . . . . . . . . 337
Overload Resolution with Named
and Optional Arguments . . . . . . . . . . . . . . . . 338
You Do It . . . . . . . . . . . . . . . . . . . . . . . . 339
Using Reference Parameters . . . . . . . . . . . . . . 339
Overloading Methods . . . . . . . . . . . . . . . . . . 341
Chapter Summary . . . . . . . . . . . . . . . . . . . . 342
Key Terms . . . . . . . . . . . . . . . . . . . . . . . 343
Review Questions . . . . . . . . . . . . . . . . . . . . 344
Exercises . . . . . . . . . . . . . . . . . . . . . . . . 349
CONTENTS

C HAP TER 9 U s in g Clas s e s and Obj ects . . . . . . . . 354


Understanding Class Concepts . . . . . . . . . . . . . . 355
Creating a Class from Which Objects Can Be
Instantiated . . . . . . . . . . . . . . . . . . . . . . 357
Creating Instance Variables and Methods . . . . . . . . . 358
x Creating Objects. . . . . . . . . . . . . . . . . . . . . 361
Passing Objects to Methods . . . . . . . . . . . . . . 363
Creating Properties . . . . . . . . . . . . . . . . . . . 365
Using Auto-Implemented Properties . . . . . . . . . . . 369
More About public and private Access
Modifiers . . . . . . . . . . . . . . . . . . . . . . . 372
Understanding the this Reference . . . . . . . . . . . . 376
Understanding Constructors . . . . . . . . . . . . . . . 379
Passing Parameters to Constructors . . . . . . . . . . . 380
Overloading Constructors . . . . . . . . . . . . . . . . 381
Using Constructor Initializers . . . . . . . . . . . . . . 383
Using Object Initializers . . . . . . . . . . . . . . . . . 385
Overloading Operators . . . . . . . . . . . . . . . . . . 389
Declaring an Array of Objects . . . . . . . . . . . . . . . 394
Using the Sort() and BinarySearch() Methods
with Arrays of Objects . . . . . . . . . . . . . . . . 395
Apago PDF Enhancer
Understanding Destructors . . . . . . . . . . . . . . . . 399
Understanding GUI Application Objects . . . . . . . . . . 402
You Do It . . . . . . . . . . . . . . . . . . . . . . . . 404
Creating a Class and Objects . . . . . . . . . . . . . . 404
Using Auto-Implemented Properties . . . . . . . . . . . 407
Adding Overloaded Constructors To a Class . . . . . . . 407
Creating an Array of Objects . . . . . . . . . . . . . . 409
Chapter Summary . . . . . . . . . . . . . . . . . . . . 411
Key Terms . . . . . . . . . . . . . . . . . . . . . . . 413
Review Questions . . . . . . . . . . . . . . . . . . . . 416
Exercises . . . . . . . . . . . . . . . . . . . . . . . . 420

C HAP TER 10 In t ro du ct io n t o I n heri tance . . . . . . . . 427


Understanding Inheritance . . . . . . . . . . . . . . . . 428
Understanding Inheritance Terminology . . . . . . . . . 431
Extending Classes . . . . . . . . . . . . . . . . . . . . 433
Using the protected Access Specifier . . . . . . . . . . 435
Overriding Base Class Methods . . . . . . . . . . . . . . 440
Accessing Base Class Methods from a Derived Class . . . 443
Understanding How a Derived Class Object “is an”
Instance of the Base Class . . . . . . . . . . . . . . . 445
Using the Object Class . . . . . . . . . . . . . . . . . 447
Using the Object Class’s GetType() Method . . . . . 449
CONTENTS

Using the Object Class’s ToString () Method . . . . . . 449


Using the Object Class’s Equals() Method . . . . . . 450
Using the Object Class’s GetHashCode() Method . . . 451
Working with Base Class Constructors . . . . . . . . . . . 453
Using Base Class Constructors That Require Arguments . . 454
Creating and Using Abstract Classes . . . . . . . . . . . 456 xi
Creating and Using Interfaces. . . . . . . . . . . . . . . 460
Using Extension Methods . . . . . . . . . . . . . . . . . 464
Recognizing Inheritance in GUI Applications
and Recapping the Benefits of Inheritance . . . . . . . . 467
You Do It . . . . . . . . . . . . . . . . . . . . . . . . 469
Extending a Class . . . . . . . . . . . . . . . . . . . 471
Using Base Class Members in a Derived Class . . . . . . 472
Adding Constructors to Base and Derived Classes . . . . 475
Chapter Summary . . . . . . . . . . . . . . . . . . . . 476
Key Terms . . . . . . . . . . . . . . . . . . . . . . . 477
Review Questions . . . . . . . . . . . . . . . . . . . . 479
Exercises . . . . . . . . . . . . . . . . . . . . . . . . 483

CH AP TER 11 E xcept io n Hand l i ng . . . . . . . . . . . 490


Apago PDF Enhancer
Understanding Exceptions . . . . . . . . . . . . . . . . 491
Purposely Generating a SystemException . . . 493
Understanding Traditional and Object-Oriented
Error-Handling Methods . . . . . . . . . . . . . . . . . 495
Understanding Object-Oriented Exception-Handling
Methods . . . . . . . . . . . . . . . . . . . . . . . 496
Using the Exception Class’s ToString()Method
and Message Property . . . . . . . . . . . . . . . . . 499
Catching Multiple Exceptions . . . . . . . . . . . . . . 502
Using the finally Block . . . . . . . . . . . . . . . . 507
Handling Exceptions Thrown from Outside
Methods. . . . . . . . . . . . . . . . . . . . . . . . 509
Tracing Exceptions Through the Call Stack . . . . . . . 513
A Case Study: Using StackTrace . . . . . . . . . . . 514
Creating Your Own Exception Classes . . . . . . . . . . 518
Rethrowing an Exception . . . . . . . . . . . . . . . . 522
You Do It . . . . . . . . . . . . . . . . . . . . . . . . 524
Purposely Causing Exceptions . . . . . . . . . . . . 524
Handling Exceptions . . . . . . . . . . . . . . . . . 526
Catching Various Exception Types. . . . . . . . . . . 527
Chapter Summary . . . . . . . . . . . . . . . . . . . . 529
Key Terms . . . . . . . . . . . . . . . . . . . . . . . 530
Review Questions . . . . . . . . . . . . . . . . . . . . 531
Exercises . . . . . . . . . . . . . . . . . . . . . . . . 536
CONTENTS

C HAP TER 12 U s in g Co n t ro l s . . . . . . . . . . . . . 540


Understanding Controls . . . . . . . . . . . . . . . . 541
Examining the IDE’s Automatically Generated Code . . . . . 545
Setting a Control’s Font . . . . . . . . . . . . . . . . 549
Using a LinkLabel . . . . . . . . . . . . . . . . . . . 551
xii Adding Color to a Form . . . . . . . . . . . . . . . . . 555
Using CheckBox and RadioButton Objects . . . . . . . 557
Adding a PictureBox to a Form . . . . . . . . . . . . 561
Adding ListBox, CheckedListBox, and ComboBox
Controls to a Form . . . . . . . . . . . . . . . . . 564
Adding MonthCalendar and DateTimePicker
Controls to a Form . . . . . . . . . . . . . . . . . 569
Working with a Form’s Layout . . . . . . . . . . . . . . 573
Understanding GroupBoxes and Panels . . . . . . . . 576
Adding a MenuStrip to a Form . . . . . . . . . . . . . 577
Using Other Controls . . . . . . . . . . . . . . . . . 580
You Do It . . . . . . . . . . . . . . . . . . . . . . . . 580
Adding Labels to a Form and Changing their
Properties . . . . . . . . . . . . . . . . . . . . . . 580
Examining the Code Generated by the IDE . . . . . . . . 583
Adding CheckBoxes to a Form . . . . . . . . . .
Apago PDF Enhancer . . . 586
Adding RadioButtons to a Form . . . . . . . . . . . 592
Chapter Summary . . . . . . . . . . . . . . . . . . . . 595
Key Terms . . . . . . . . . . . . . . . . . . . . . . . 597
Review Questions . . . . . . . . . . . . . . . . . . . . 598
Exercises . . . . . . . . . . . . . . . . . . . . . . . . 602

CH APTER 13 Han dlin g E ve nt s . . . . . . . . . . . . . 606


Event Handling . . . . . . . . . . . . . . . . . . . . . 607
Understanding Delegates . . . . . . . . . . . . . . . . . 611
Creating Composed Delegates . . . . . . . . . . . . . 613
Declaring Your Own Events and Handlers and Using
the Built-in EventHandler. . . . . . . . . . . . . . . 615
Using the Built-in EventHandler . . . . . . . . . . . . 619
Handling Control Component Events. . . . . . . . . . . 621
Handling Mouse and Keyboard Events . . . . . . . . . . . 626
Handling Mouse Events . . . . . . . . . . . . . . . . . 626
Handling Keyboard Events . . . . . . . . . . . . . . . 628
Managing Multiple Controls . . . . . . . . . . . . . . . 631
Defining Focus. . . . . . . . . . . . . . . . . . . . . 631
Handling Multiple Events with a Single Handler . . . . . . 632
Continuing to Learn about Controls and Events . . . . . . 635
CONTENTS

You Do It . . . . . . . . . . . . . . . . . . . . . . . . 635
Creating Delegates. . . . . . . . . . . . . . . . . . . 635
Creating a Composed Delegate . . . . . . . . . . . . . 637
Creating a Delegate that Encapsulates Instance
Methods . . . . . . . . . . . . . . . . . . . . . . . 640
Creating an Event Listener . . . . . . . . . . . . . . . 642 xiii
Using TabIndex . . . . . . . . . . . . . . . . . . . 644
Associating One Method with Multiple Events . . . . . . . 645
Chapter Summary . . . . . . . . . . . . . . . . . . . . 646
Key Terms . . . . . . . . . . . . . . . . . . . . . . . 648
Review Questions . . . . . . . . . . . . . . . . . . . . 648
Exercises . . . . . . . . . . . . . . . . . . . . . . . . 653

C HAP TER 14 F iles an d St ream s . . . . . . . . . . . . 656


Computer Files and the File and Directory
Classes . . . . . . . . . . . . . . . . . . . . . . . . 657
Using the File and Directory Classes . . . . . . . . . 658
Understanding Data Organization Within a File . . . . . . . 662
Understanding Streams . . . . . . . . . . . . . . . . . 665
Writing to and Reading From a Sequential Access
Text File . . . . . . . . . . . . . . . . . . .
Apago PDF Enhancer . . . . . 669
Writing Data to a Sequential Access Text File . . . . . . . 669
Reading from a Sequential Access Text File . . . . . . . 672
Searching a Sequential Text File. . . . . . . . . . . . . . 675
Understanding Serialization and Deserialization . . . . . . . 678
You Do It . . . . . . . . . . . . . . . . . . . . . . . . 682
Creating a File . . . . . . . . . . . . . . . . . . . . . 682
Reading from a File . . . . . . . . . . . . . . . . . . 684
Using the Seek() Method . . . . . . . . . . . . . . . 685
Creating a Text File in a GUI Environment . . . . . . . . . 687
Reading Data from a Text File into a Form . . . . . . . . 691
Chapter Summary . . . . . . . . . . . . . . . . . . . . 696
Key Terms . . . . . . . . . . . . . . . . . . . . . . . 698
Review Questions . . . . . . . . . . . . . . . . . . . . 700
Exercises . . . . . . . . . . . . . . . . . . . . . . . . 704

C HAP TER 15 U s in g LINQ t o A ccess Data


in C# Pro gram s . . . . . . . . . . . . . 708
Understanding Relational Database Fundamentals . . . . . . 709
Creating Databases and Table Descriptions . . . . . . . . 712
Identifying Primary Keys . . . . . . . . . . . . . . . . 714
Understanding Database Structure Notation . . . . . . . 715
CONTENTS

Creating SQL Queries . . . . . . . . . . . . . . . . . . 716


Creating an Access Database . . . . . . . . . . . . . . . 718
Understanding Implicitly Typed Variables . . . . . . . . . . 721
Understanding LINQ . . . . . . . . . . . . . . . . . . . 723
Retrieving Data from an Access Database in C# . . . . . . 727
xiv
Using LINQ Queries with an Access Database Table . . . . . 731
Using LINQ Operators to Sort and Group Data . . . . . . . 736
You Do It . . . . . . . . . . . . . . . . . . . . . . . . 740
Adding a Dataset to a Project . . . . . . . . . . . . . . 740
Querying a Dataset. . . . . . . . . . . . . . . . . . . 743
Allowing the User to Provide Selection Criteria . . . . . . 744
Grouping Data . . . . . . . . . . . . . . . . . . . . . 747
Chapter Summary . . . . . . . . . . . . . . . . . . . . 750
Key Terms . . . . . . . . . . . . . . . . . . . . . . . 752
Review Questions . . . . . . . . . . . . . . . . . . . . 754
Exercises . . . . . . . . . . . . . . . . . . . . . . . . 758

AP PEN DIX A Oper at o r Pre cede nce And Associ ati v i ty . . . 764

AP PEN DIX B U n der s t an ding Numberi ng Sy stems


an dApago
Co m pu t erPDFCo desEnhancer
. . . . . . . . . . . 766

AP PEN DIX C U s in g T h e IDE E d i tor . . . . . . . . . . . 775

Glo s s ar y . . . . . . . . . . . . . . . . 779

In dex . . . . . . . . . . . . . . . . . 799
Preface
xv

Microsoft Visual C# 2010, Fourth edition provides the beginning


programmer with a guide to developing programs in C#. C# is a
language developed by the Microsoft Corporation as part of the
.NET Framework and Visual Studio platform. The .NET Framework
contains a wealth of libraries for developing applications for the
Windows family of operating systems. With C#, you can build small,
reusable components that are well-suited to Web-based program-
ming applications. Although similar to Java and C++, many features
of C# make it easier to learn and ideal for the beginning programmer.
You can program in C# using a simple text editor and the command
prompt, or you can manipulate program components using Visual
Studio’s sophisticated Integrated Development Environment. This
book provides you with the tools to use both techniques.
This textbook assumes that you have little or no programming
Apago PDF Enhancer
experience. The writing is nontechnical and emphasizes good pro-
gramming practices. The examples are business examples; they do
not assume mathematical background beyond high school business
math. Additionally, the examples illustrate one or two major points;
they do not contain so many features that you become lost following
irrelevant and extraneous details. This book provides you with a solid
background in good object-oriented programming techniques and
introduces you to object-oriented terminology using clear, familiar
language.

Organization and Coverage


Microsoft Visual C# 2010 presents C# programming concepts,
enforcing good style, logical thinking, and the object-oriented
paradigm. Chapter 1 introduces you to the language by letting you
create working C# programs using both the simple command line and
the Visual Studio environment. In Chapter 2 you learn about data and
how to input, store, and output data in C#. Chapter 3 provides a quick
start to creating GUI applications. You can take two approaches:
• You can cover Chapter 3 and learn about GUI objects so that you
can create more visually interesting applications in the subsequent
P R E FA C E

chapters on decision making, looping, and array manipulation.


These subsequent chapters confine GUI examples to the end of the
chapters, so you can postpone GUI manipulation if you want.
• You can skip Chapter 3 until learning the fundamentals of decision
making, looping, and array manipulation, and until studying
xvi object-oriented concepts such as classes, objects, polymorphism,
inheritance, and exception handling. Then, after Chapter 11, you
can return to Chapter 3 and use the built-in GUI component
classes with a deeper understanding of how they work.
In Chapters 4, 5, and 6, you learn about the classic programming
structures—making decisions, looping, and manipulating arrays—and
how to implement them in C#. Chapters 7 and 8 provide a thorough
study of methods, including passing parameters into and out of
methods and overloading them.
Chapter 9 introduces the object-oriented concepts of classes,
objects, data hiding, constructors, and destructors. After completing
Chapters 10 and 11, you will be thoroughly grounded in the object-
oriented concepts of inheritance and exception handling, and will
be able to take advantage of both features in your C# programs.
Chapter 12 continues the discussion of GUI objects from Chapter 3.
You will learn about controls, how to set their properties, and how
Apago PDF Enhancer
to make attractive, useful, graphical, and interactive programs.
Chapter 13 takes you further into the intricacies of handling events
in your interactive GUI programs. In Chapter 14, you learn to save
data to and retrieve data from files. In Chapter 15 you learn how to
interact with databases in C# programs—an increasingly valuable
skill in the information-driven business world. C# supports LINQ
(Language INtegrated Query) statements, which allow you to
integrate SQL-like queries into C# programs; Chapter 15 provides
you with the fundamentals of this important technology.

New to this Edition!


Microsoft Visual C# 2010 is a superior textbook because it also
includes the following new features:
C# 4.0 IN VISUAL STUDIO 2010 This edition is written and tested
using the latest edition of C#.
VIDEO LESSONS Each chapter includes three or more video les-
sons produced by the author. These short videos provide instruc-
tion, further explanation, or background about a topic covered in the
corresponding chapter. These videos are especially useful for online
classes, for student review before exams, and for students who are
audio learners.
P R E FA C E

EARLY GUI APPLICATIONS Students now can begin to cre-


ate GUI applications in Chapter 3. The earlier introduction helps
engage students who have used GUI applications their entire lives.
In subsequent chapters on selections, loops, arrays, and methods,
students apply concepts to applications in both console and GUI
environments. This keeps some examples simple while increasing the
xvii
understanding that input, processing, and output are programming
universals no matter what interface is used. The book is structured
so that students who want to skip Chapter 3 until they understand
object-oriented programming can do so with no loss of continuity.
EXPANDED COVERAGE OF METHODS Instructions for using
methods have been expanded and divided into two chapters. The
introductory method chapter covers the basics of calling methods,
passing arguments, and returning values. The advanced chapter dis-
cusses reference parameters, output parameters, optional parameters,
parameter arrays, overloading methods, and avoiding ambiguity.
(Optional parameters are a new feature in C# 4.0.)
MORE ENGAGING EXERCISES ON SPECIFIC TOPICS Many
chapters have additional exercises that employ string manipulation and
enumerations. Gaming exercises have been added to many chapters.

Apago PDF Enhancer


Features of the Text
Microsoft Visual C# 2010 also includes the following features:
OBJECTIVES Each chapter begins with a list of objectives so you
know the topics that will be presented in the chapter. In addition to
providing a quick reference to topics covered, this feature offers a use-
ful study aid.
NOTES These tips provide additional information—for
example, an alternative method of performing a procedure,
another term for a concept, background information on a
technique, or a common error to avoid.

FIGURES Each chapter contains many figures. Code figures are


most frequently 25 lines or shorter, illustrating one concept at a time.
Frequently placed screen shots show exactly how program output
appears. In this edition, all C# keywords that appear in figures are
bold to help them stand out from programmer-created identifiers.
SUMMARIES Following each chapter is a summary that recaps the
programming concepts and techniques covered in the chapter. This
feature helps you to recap and check your understanding of the main
points in each chapter.
P R E FA C E

KEY TERMS Each chapter includes a list of newly introduced vocab-


ulary, shown in the order of appearance in the text. The list of key
terms provides a review of the major concepts in the chapter.
YOU DO IT In each chapter, step-by-step exercises help the student
create multiple working programs that emphasize the logic a pro-
xviii grammer uses in choosing statements. This section enables students
to achieve success on their own—even students in online or distance
learning classes.
TWO TRUTHS AND A LIE This short quiz appears after each main
chapter section, with answers provided. This quiz contains three
statements—two true and one false—and the student must identify
the false one. Over the years, students have requested answers to
problems, but we have hesitated to distribute them in case instructors
want to use problems as assignments or test questions. These quizzes
provide students with immediate feedback as they read, without “giv-
ing away” answers to the existing multiple-choice and programming
problem questions.
REVIEW QUESTIONS Each chapter contains 20 multiple-choice
review questions that provide a review of the key concepts in the chapter.
EXERCISES Each chapter concludes with meaningful programming
Apago PDF Enhancer
exercises that provide additional practice of the skills and concepts
you learned in the chapter. These exercises increase in difficulty and
allow you to explore logical programming concepts.
DEBUGGING EXERCISES Each chapter contains four pro-
grams that have syntax and/or logical errors for you to fix.
Completing these exercises provides valuable experience in
locating errors, interpreting code written by others, and observ-
ing how another programmer has approached a problem.
UP FOR DISCUSSION Each chapter concludes with a few
thought-provoking questions that concern programming in
general or C# in particular. The questions can be used to
start classroom or online discussions, or to develop and
encourage research, writing, and language skills.
PROGRAM CODE The downloadable student files provide code for
each full program presented in the chapter figures. Providing the code
on disk allows students to run it, view the results for themselves, and
experiment with multiple input values. Having the code on disk also
enables students to experiment with the code without a lot of typing.
GLOSSARY A glossary contains definitions for all key terms in the
book, presented in alphabetical order.
P R E FA C E

QUALITY Every program example in the book, as well as every exer-


cise, case project, and game solution, was tested by the author and
again by a Quality Assurance team using Visual Studio 2010.

Instructor Resources
xix
The following supplemental materials are available when this book is
used in a classroom setting. All of the teaching tools for this book are
provided to the instructor on a single CD-ROM, and are also avail-
able for download at the companion site for the text (www.cengage.
com/coursetechnology).
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.
• Solutions to Review Questions, end-of-chapter programming exer-
cises, debugging exercises, and Up For Discussion questions.
®
EXAMVIEW This textbook is accompanied by ExamView, a powerful
testing software package that allows instructors to create and admin-
ister printed, computer (LAN-based), and Internet exams. ExamView
Apago PDF Enhancer
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. The computer-based and
Internet testing components allow students to take exams at their com-
puters, and save the instructor time by grading each exam automatically.
POWERPOINT PRESENTATIONS This book comes with Microsoft
PowerPoint slides for each chapter. These slides are included as a
teaching aid for classroom presentation; teachers can make them
available on the network for chapter review or print them for class-
room distribution. Instructors can add their own slides for additional
topics they introduce to the class.
SOLUTION FILES Solutions to all “You Do It” exercises and end-of
chapter exercises are provided on the Instructor Resources CD-ROM
and on the Course Technology Web site at www.cengage.com/
coursetechnology. The solutions are password protected.
DISTANCE LEARNING Cengage Learning is proud to present online
test banks in WebCT and Blackboard to provide the most complete
and dynamic learning experience possible. Instructors are encouraged
to make the most of the course, both online and offline. For more
information on how to access the online test bank, contact your local
Course Technology sales representative.
P R E FA C E

Acknowledgments
I would like to thank all of the people who helped to make this book
a reality, especially Dan Seiter, the development editor, who once
again worked against multiple, aggressive deadlines to make this
book into a superior instructional tool. Thanks also to Alyssa Pratt,
xx Senior Product Manager; Amy Jollymore, Acquisitions Editor; and
Lisa Weidenfeld, Content Project Manager. I am grateful to be able to
work with so many fine people who are dedicated to producing good
instructional materials.
I am also grateful to the many reviewers who provided helpful
comments and encouragement during this book’s development,
including Matthew Butcher, Mohave Community College;
Dan Guilmette, Cochise College; and Jorge Vallejos, Columbus
State Community College.
Thanks, too, to my husband, Geoff, for his constant support and
encouragement. Finally, this book is dedicated to Andrea and Forrest,
wishing them a lifetime of happiness together.
Joyce Farrell

Apago PDF Enhancer


Read This
Before You
Begin
xxi

To the User
To complete the debugging exercises in this book, you will need data
files that have been created specifically for the book. Your instructor
will provide the data files to you. You also can obtain the files
electronically from the Course Technology Web site by connecting to
www.cengage.com/coursetechnology and then searching for this book
Apago PDF Enhancer
title. Note that you can use a computer in your school lab or your
own computer to complete the exercises in this book.
The data files for this book are organized such that the examples and
exercises are divided into folders named Chapter.xx, where xx is the
chapter number. You can save these files in the same folders unless
specifically instructed to do otherwise in the chapter.

Using Your Own Computer


To use your own computer to complete the steps and exercises, you
will need the following:
SOFTWARE Microsoft Visual C# 2010, including the Microsoft.NET
Framework. If your book came with a copy of the software, you may
install it on your computer and use it to complete the material.
HARDWARE Minimum requirements identified by Microsoft are a
1.6 GHz CPU, 1024 MB of RAM, 3 GB of available hard disk space,
5400 RPM hard disk drive, DirectX 9-capable video card that runs at
1280×1024 or higher display resolution, and a DVD-ROM drive.
OPERATING SYSTEM Windows 7, Vista, or XP.
BEFORE YOU BEGIN

DATA FILES You will not be able to complete the debugging exer-
cises in this book using your own computer unless you have the data
files. You can get the data files from your instructor, or you can obtain
them electronically from the Course Technology Web site by con-
necting to www.cengage.com/coursetechnology and searching for this
book title. Additionally, the data files include code for every example
xxii
shown in a figure in the book.

To the Instructor
To complete the debugging exercises and chapters in this book, your
users must work with a set of data files. These files are included on
the Instructor Resources CD. You can also obtain these files electron-
ically through the Course Technology Web site at www.cengage.com/
coursetechnology. Follow the instructions in the Help file to copy the
user files to your server or stand-alone computer. You can view the
Help file using a text editor such as WordPad or Notepad.
Once the files are copied, you can make copies for the users yourself
or tell them where to find the files so they can make their own copies.

License
Apago to Use
PDFDataEnhancer
Files
You are granted a license to copy the files that accompany this book
to any computer or computer network used by people who have
purchased this book.
A First Program
CHAPTER 1
Using C#

In this chapter you will:

 Learn about programming


 Learn about
Apago PDF
procedural Enhancerprogramming
and object-oriented
 Learn about the features of object-oriented programming
languages
 Learn about the C# programming language
 Write a C# program that produces output
 Learn how to select identifiers to use within your programs
 Improve programs by adding comments and using the
System namespace
 Write and compile a C# program using the command
prompt and using Visual Studio
Exploring the Variety of Random
Documents with Different Content
the last verse, they advance towards the opposite side, who, when
they see the direction in which they are coming, form two arches, by
three of the players holding up their arms, the dukes’ side going
through one arch and returning through the other, bringing the
chosen girl with them. One Clapham version is played in a totally
different manner: the maidens form a circle instead of a line, and the
duke stands outside this until he is admitted at the line which says,
“let him in.” At the conclusion of the dialogue he breaks in and
carries one player off. This is an unusual form; I have only met with
one other instance of it.
(d.) The action in many of these versions is described as very
spirited: coquetry, contempt, and annoyance being all expressed in
action as the words of the game demands. The dancing movement
of the boys in the first verse to imitate riding, though belonging to
the earlier forms, is, with the exception of two or three versions, only
retained in those which are commenced by one player, partly,
perhaps, because of the difficulty three or more players experience
in “riding” or “prancing” while holding each other’s hands in line
form. I have seen the game played when the “prancing” of the dukes
(in a game where there were a dozen or more players on each side
at starting, as in the Dorset version) was as important a feature as
the maidens’ actions in the other verses. I think the oldest form of
the game is that played by a fairly equal number of players on each
side, boys on one side and girls on the other, rather than that of
“one” or “three” players on the dukes’ side, and all the others
opposite. The game then began with the present words, “Here come
three dukes;” these three each chose a girl at the same time, and
when these three were wived, another three “dukes” would pair with
three more of the girls, and after that another three, and so on. This
form would account for the modern idea that the number of dukes
increases on every occasion that the verses are sung, after the first
wife has been taken over, and until all the girls have been thus
chosen. This idea is expressed in some versions by the change of
words: “Here’s a fourth [or fifth, and so on] duke come a riding” to
take a wife, the chosen maiden becoming a duke as soon as she has
passed over on to the dukes’ side. The process of innovation may be
traced by the methods of playing. Thus, in one version played at
Barnes (similar in other respects to No. 10), beginning “three dukes
a riding,” three girls were chosen by the three first dukes, one by
each, at the same time, and all three girls walked across with the
three dukes to the boys’ line, and stood next their respective
partners. In two imperfect versions I have obtained in Regent’s Park,
London, the same principle occurs. One girl began—“One duck
comes a ridin’,” and two girls from the opposite side walked across;
the other “Five dukes come here a ridin’” was played by five players
on each side, and this was continued throughout. When the verses
were said, each of the five dukes took a player from the opposite
side and danced round with her. Again, in those versions
(Symondsbury and Barnes), where when one player is left on the
maidens’ side without a partner, and all the dukes are mated, the
additional verse is sung, and this player is taken over too. Beyond
these versions are the large number beginning with three or more
children singing the formula of “three dukes,” and choosing one girl
at a time, until all are taken over on to the dukes’ side. Finally, there
are the versions, more in accord with modern ideas, which
commence with one duke coming for a wife, and continue by the
girls taken over counting as dukes, the formula changing into two
dukes, and so on.
If this correctly represents the line of decadence in this game, those
versions in which additional verses appear are, I think, instances of
the tacking on of verses from the “invitation to the dance” or “May”
games; particularly in the cases in which the words “Now I’ve got my
bonny lass” appear. The Earls Heaton version is curious, in that it has
several verses which remind us of the old and practically obsolete
“Keys of Canterbury” (Halliwell, 96). It may well be that a
remembered fragment of that old ballad, which was probably once
danced as a dramatic round, has been tacked on to this game. The
expression “walk with me,” or “walk abroad with me,” is significant of
an engaged or betrothed couple. “I’m walking or walking out with so
and so” is still an expression used by young men and young women
to indicate an engagement. “She did ought to be married now;
she’ve walked wi’ him mor’n’er a year now.” Some of the versions
show still more marked signs of decadence. The altered wording,
“Here comes a Jew a riding,” “Here comes the Duke of Rideo,” “A
duck comes a ridin’,” and the Scotch “Campsie Dukes a riding;” a
Berkshire version, collected by Miss Thoyts (Antiquary, xxvii. p. 195),
similar to the Shropshire game, but with a portion of the verse of
“Milking Pails” added to it, and the refrain of “Ransome, tansome,
tismatee;” together with the disappearance of some of the verses,
are all evidently the results of the words being learnt orally, and
imperfectly understood, or not understood at all.
In this game, said in Lancashire to be the “oldest play of all,” judging
both by the words and method of playing, we have, I believe, a
distinct survival or remembrance of the tribal marriage—marriage at
a period when it was the custom for men of a clan to seek wives
from the girls of another clan, both clans belonging to one tribe. The
game is a purely marriage game, and marriage in a matter-of-fact
way. Young men of a clan or village arrive at the abode of another
clan for the purpose of seeking wives, probably at a feast or fair
time. The maidens are apparently ready and expecting their arrival.
They are as willing to become wives as the dukes are to become
husbands. It is not marriage by force or capture, though the
triumphant carrying off of a wife appears in some versions. It is
exogamous marriage custom, after the tribe had settled down and
arranged their system of marriage in lieu of a former more rude
system of capture. The suggested depreciation of the girls, and their
saucy rejoinders, may be looked upon as so much good-humoured
chaff and banter exchanged between the two parties to enhance
each other’s value, and to display their wit. While it does not follow
that the respective parties were complete strangers to one another,
these lines may indicate that each individual wished “to have as
good a look round as possible” before accepting the offer made. It
will be seen that there is no mention of “love” in the game, nor is
there any individual courtship between boy and girl. The marriage
formula does not appear, nor is there any sign that a “ceremony” or
“sanction” to conclude the marriage was necessary, nor does kissing
occur in the game.
There is evidence of the tribal marriage system in the survivals of
exogamy and marriage by capture occasionally to be noted in
traditional local custom. Thus the custom recorded by Chambers
(Book of Days, i. 722) of the East Anglians (Suffolk), where whole
parishes have intermarried to such an extent that almost everybody
is related to or connected with everybody else, is distinctly a case in
point, the intermarrying of “parishes” for a long series of years
necessarily resulting in close inter-relationship. One curious effect of
this is that no one is counted as a “relation” beyond first cousins; for
if “relationship” went further than that it might “almost as well
include the whole parish.” The old proverb (also from East Anglia):

“To change the name, and not the letter,


Is a change for the worse, and not for the better;”

that is, it is unlucky for a woman to marry a man whose surname


begins with the same letter as her own, also indicates a survival of
the necessity of marrying into another clan or tribal family.
Another interesting point in the game is the refrain, “With a rancy,
tancy, tay,” which with variations accompanies all versions, and
separates this game from some otherwise akin to it. There is little
doubt that this refrain represents an old tribal war cry, from which
“slogans” or family “cries” were derived. These cries were not only
used in times of warfare, tribes were assembled by them, each
leader of a clan or party having a distinguishing cry and blast of a
horn peculiar to himself, and the sounding of this particular blast or
cry would be recognised by men of the same party, who would go to
each other’s assistance if need were. The refrain is sung by all the
players in Oxfordshire and Lancashire, and in some versions the
players in this game put their hands to their mouths as if imitating a
blast from a horn, and a Lancashire version (about 1820-1830),
quoted by Miss Burne, has for the refrain, “With a rancy, tancy, terry
boys horn, with a rancy, tancy, tee.” “The burden,” says Miss Burne,
“evidently represented a flourish of trumpets.” The Barnes version,
“With a rancy, tancy, terrimus hey!” and many others confirm this.
An interesting article by Dr. Karl Blind (Antiquary, ix. 63-72), on the
Hawick riding song, “Teribus ye Teri Odin,” points out that this
slogan, which occurs in the “Hawick Common-Riding Song,” a song
used at the annual Riding of the Marches of the Common, is an
ancient Germanic war-cry. Dr. Blind, quoting from a pamphlet,
Flodden Field and New Version of the Common Riding Song, says, “It
is most likely that the inspiring strains of ‘Terribus’ would be the
marching tune of our ancestors when on their way for Flodden Field
and other border battles, feuds, and frays. The words of the
common-riding song have been changed at various periods,
according to the taste and capacity of poets and minstrels, but the
refrain has remained little altered. . . . The origin of the ancient and,
at one time, imperative ceremony of the common-riding is lost in
antiquity, and this old, no longer understood, exclamation, ‘Teribus
ye Teri Odin,’ has (says Dr. Blind) all through ages in the meanwhile
clung to that ceremony.”
If we can fairly claim that the words of this game have preserved an
old slogan or tribal cry, an additional piece of evidence is supplied to
the suggestion that the game is a reflection of the tribal marriage—a
reflection preserved by children of to-day by means of oral tradition
from the children of a thousand years ago or more, who played at
games in imitation of the serious and ordinary actions of their elders.
[Addendum] [Addendum]

Three Flowers
My mistress sent me unto thine,
Wi’ three young flowers baith fair and fine—
The Pink, the Rose, and the Gilliflower:
And as they here do stand,
Whilk will ye sink, whilk will ye swim,
And whilk bring hame to land?
A group of lads and lasses being assembled round the fire, two leave
the party and consult apart as to the names of three others, young
men or girls, whom they designate Red Rose, the Pink, and the
Gilliflower. If lads are first pitched upon, the two return to the
fireside circle, and having selected a lass, they say the above verse
to her. The maiden must choose one of the flowers named, on which
she passes some approving epithet, adding, at the same time, a
disapproving rejection of the other two; for instance, I will sink the
Pink, swim the Rose, and bring home the Gilliflower to land. The two
young men then disclose the names of the parties upon whom they
had fixed those appellations respectively, when of course it may
chance that she has slighted the person she is understood to be
most attached to, or chosen him whom she is believed to regard
with aversion; either of which events is sure to throw the company
into a state of outrageous merriment.—Chambers’ Popular Rhymes,
p. 127. Mr. W. Ballantyne has given me a description of this game as
played at Biggar when he was a boy, which is practically the same as
this.

Three Holes

Three holes were made in the ground by the players driving the
heels of their boots into the earth, and then pirouetting. The game
was played with the large marbles (about the size of racket balls)
known as “bouncers,” sometimes as “bucks.” The first boy stood at
“taw,” and bowled his marble along the ground into 1. (It was bad
form to make the holes too large; they were then “wash-hand
basins,” and made the game too easy.) Taking the marble in his
hand, and placing his foot against 1, he bowled the marble into 2.
He was now “going up for his firsts.” Starting at 2, he bowled the
marble into 3, and had now “taken off his firsts,” and was “coming
down for his seconds.” He then bowled the marble back again into 2,
and afterwards into 1. He then “went up for his thirds,” bowling the
marble into 2, and afterwards into 3, and had then won the game.
When he won in this fashion, he was said to have “taken off the
game.” But he didn’t often do this. In going up for his firsts, perhaps
his marble, instead of going into 2, stopped at A; then the second
boy started from taw, and, having sent his marble into 1, bowled at
A; if he hit the marble, he started for 2, from where his marble
stopped; if he missed, or didn’t gain the hole he was making for, or
knocked his antagonist’s marble into a hole, the first boy played
again, hitting the other marble, if it brought him nearer to the hole
he was making for, or else going on. In such a case as I have
supposed, it would be the player’s aim to knock A on to B, or some
place between 2 and 3, so as to enter 2, and then strike again so as
to near 3, enter 3, and strike on his way down for his seconds, and
near 2 again. These were the chances of the game; but if the boy
who started went through the game without his antagonist having a
chance, he was said “to take off the game.”—London (J. P. Emslie).

Three Jolly Welshmen


One child is supposed to be taking care of others, who take hold of
her or of each other. Three children personate the Welshmen. These
try to rob the mother or caretaker of her children. They each try to
capture as many as they can, and I think the one who gets most is
to be mother next time.—Beddgelert (Mrs. Williams).
See “Gipsy,” “Mother, Mother,” “Shepherd and Sheep,” “Witch.”

Three Knights from Spain


I. Here come two dukes all out of Spain,
A courting to your daughter Jane.

My daughter Jane, she is so young,


She can’t abide your flattering tongue.
Let her be young, or let her be old,
It is the price, she must be sold,
Either for silver or for gold.
So fare you well, my lady gay,
For I must turn another way.

Turn back, turn back, you Spanish knight,


And rub your spurs till they be bright.

My spurs they are of a costliest wrought,


And in this town they were not bought,
Nor in this town they won’t be sold,
Neither for silver, nor for gold.
So fare you well, my lady gay,
For I must turn another way.

Through the kitchen, and through the hall,


And take the fairest of them all;
The fairest is, as I can see,
Pretty Jane—come here to me.

Now I’ve got my pretty fair maid,


Now I’ve got my pretty fair maid,
To dance along with me,
To dance along with me! —Eccleshall, Halliwell’s Nursery Rhymes, p. 222.

II.Here comes three lords dressed all in green,


For the sake of your daughter Jane.

My daughter Jane, she is so young,


She learns to talk with a flattering tongue.

Let her be young, or let her be old,


For her beauty she must be sold.

My mead’s not made, my cake’s not baked,


And you cannot have my daughter Jane.
—Cambridgeshire, Halliwell’s Nursery Rhymes, p.
222.

III.We are three brethren out of Spain,


Come to court your daughter Jane.

My daughter Jane, she is too young,


And has not learned her mother tongue.

Be she young, or be she old,


For her beauty she must be sold.
So fare you well, my lady gay,
We’ll call again another day.

Turn back, turn back, thou scornful knight,


And rub thy spurs till they be bright.

Of my spurs take you no thought,


For in this town they were not bought.
So fare you well, my lady gay,
We’ll call again another day.

Turn back, turn back, thou scornful knight,


And take the fairest in your sight.
The fairest maid that I can see,
Is pretty Nancy—come to me.

Here comes your daughter, safe and sound,


Every pocket with a thousand pound,
Every finger with a gay gold ring,
Please to take your daughter in.
—Halliwell’s Nursery Rhymes, cccxxxiii.

IV.We are three brethren come from Spain,


All in French garlands;
We are come to court your daughter Jean,
And adieu to you, my darlings.
My daughter Jean, she is too young,
All in French garlands;
She cannot bide your flattering tongue,
And adieu to you, my darlings.

Be she young, or be she old,


All in French garlands;
It’s for a bride she must be sold,
And adieu to you, my darlings.

A bride, a bride, she shall not be,


All in French garlands;
Till she go through this world with me,
And adieu to you, my darlings.
[There is here a hiatus, the reply of the lovers being wanting.]

Come back, come back, you courteous knights,


All in French garlands;
Clear up your spurs, and make them bright,
And adieu to you, my darlings.

[Another hiatus.]

Smell my lilies, smell my roses,


All in French garlands;
Which of my maidens do you choose?
And adieu to you, my darlings.

Are all your daughters safe and sound?


All in French garlands;
Are all your daughters safe and sound?
And adieu to you, my darlings.

In every pocket a thousand pounds,


All in French garlands;
On every finger a gay gold ring,
And adieu to you, my darlings.
—Chambers’s Popular Rhymes, 143.

V. Here come three Spaniards out of Spain,


A courting to your daughter Jane.

Our daughter Jane, she is too young,


She hath not learnt the Spanish tongue.

Whether she be young, or whether she be old,


It’s for her beauty she must be sold.

Turn back, turn back, ye Spanish knight,


And rub your spurs till they be bright.

Our spurs are bright and richly wrought,


For in this town they were not bought;
And in this town they shan’t be sold,
Neither for silver nor for gold.

Pass through the kitchen, and through the hall,


And pick the fairest of them all.

This is the fairest I can see,


So pray, young lady, walk with me.
—Leicester (Miss Ellis).

VI.Here come three Spaniards out of Spain,


A courting of your daughter Jane.

My daughter Jane, she is too young,


She has not learned the Spanish tongue.

Whether she be young or old,


She must have a gift of gold;
So fare you well, my lady gay,
We’ll turn our heads another way.
Come back, come back, thou Spanish knight,
And pick the fairest in this—Addy’s
night. Sheffield Glossary.

There were three lords they came from Spain,


VII.
They came to court my daughter Jane;

My daughter Jane, she is too young


To hear your false and flattering tongue.

So fare thee well, your daughter Jane,


I’ll call again, another day, another year.

Turn back, turn back, and choose


The fairest one that you can see.

The fairest one that I can see,


Is pretty Jane, will you come with me.

[Jane says No.]

The proud little girl, she won’t come out, she won’t come out, to
help us with our dancing;
So fare you well, I’ll come again another day.

Turn back, turn back, and choose


The fairest one that you can see.

The fairest one that I can see,


Is pretty Sarah, will you come with me?

[Yes.]

Now we have got the pretty fair maid


To help us with our dancing,
Dance round the ring.
—Belfast (W. H. Patterson).

There was one lord came out of Spain,


VIII.
He came to court our daughter Jane.

Our daughter Jane, she is too young,


To be controlled by flattering tongue.

Oh! fare thee well. Oh! fare thee well,


I’ll go and court some other girl.

Come back, come back, your coat is wide,


And choose the fairest on our side.

The fairest one that I can see,


Come unto me, come unto me.
—Belfast (W. H. Patterson).

IX.There were three lords came out of Spain,


They came to court my daughter Jane;

My daughter Jane, she is too young


To bear your false and flattering tongue.

So fare you well, so fare you well,


I’ll go and court some other girl.

Come back, come back, your coat is white,


And choose the fairest in your sight.

The fairest one that I can see,


Is [ ] come unto me.
—Belfast (W. H. Patterson).

X. Here come three dukes dressed all in green,


They come to court your daughter Jane.

My daughter Jane, she is too young


To understand your flattering tongue.

Let her be young, or let her be old,


It is for her beauty she must be sold.
Eighteenpence would buy such a wench,
As either you or your daughter Jane.[10]
—Middlesex (from Mrs. Pocklington-Coltman’s
maid).

XI.There came a king from Spain,


To court your daughter Jane.

My daughter Jane, she’s yet too young


To be deluded by a flattering tongue.

Whether she’s old, or whether she’s young,


It’s for her beauty she must come.

Then turn about, her coat is thin,


And seek the fairest of your right.

The fairest one that I can see


Is fair and lovely Jan-ie.

Then here’s my daughter safe and sound,


And in her pocket three hundred pound,
And on her finger a gay gold ring,
She’s fit to walk with any king.
—Annaverna, Ravensdale, Co. Louth (Miss R.
Stephens).

There came three dukes a-riding, riding, riding;


XII.
Oh! we be come all out of Spain,
All for to court your daughter Jane.

My daughter Jane, she is too young,


She has not learned her mother-tongue.

Let her be young, or let her be old,


The fate of beauty’s to be sold.

Here’s my daughter safe and sound,


And in her pocket a thousand pound,
And on her finger a gay gold ring.

Here’s your daughter not safe nor sound,


And in her pocket no thousand pound,
And on her finger no gay gold ring;
Open your door and take —London
her in. (Miss Dendy).

There came three dukes all out of Spain,


XIII.
All for to court your daughter Jane.

My daughter Jane, she is too young,


She has not learned her mother-tongue.

Let her be young, let her be old,


The fate of beauty’s to be sold.

Walk through the parlour, walk through the hall,


And choose the fairest one of all.

The fairest one that I can see


Is little ——, so come to me. No!

Will you come? No!

Naughty one, naughty one, you won’t come out


To join us in our dancing!
Will you come? Yes!

Now we’ve got a pretty fair one


To join us in our dancing.
—Colleyhurst, Manchester (Miss Dendy).

Two poor gentlemen are come out of Spain,


XIV.
Come to court your daughter Jane.

My daughter Jane, is yet too young


To understand your flattering tongue.
Let her be young, or let her be old,
She must be sold for Spanish gold.

Turn back, turn back, you haughty knight,


And take the fairest in your sight.

This is the fairest I can see,


So ( ) must come to me. —Bexley Heath (Miss Morris).

XV.Here come three lords all dressed in green,


All for the sake of your daughter Jane.

My daughter Jane, she is so young,


She doesn’t know her mother-tongue.

[Or,

My cake ain’t baked, my ban [qy. beer or barm] ain’t brewed,


And yew can’t hev my daughter Jane.]

Fie upon you and your daughter Jane; [scornfully,]


Eighteenpence will buy a good wench,
As well as you and your daughter Jane.
—Swaffham, Norfolk (Miss Matthews).

Here come three lords all dressed in green,


XVI.
Here come three lords all come from Spain,
All for the sake of your daughter Jane.

My daughter Jane, she is so young,


She hath no knowledge in her tongue.
—Kent (Miss Fowler).

I am a gentleman come from Spain;


XVII.
I’ve come to court your daughter Jane.

My daughter Jane, is yet too young


To understand your flattering tongue.
Let her be young, or let her be old,
She must be sold for Spanish gold.
So fare thee well, my lady gay,
I’ll call upon you another day.

Turn back, turn back, you saucy lad,[11]


And choose the fairest you can spy!

The fairest one that I can see


Is pretty Miss ——. Come to me!

I’ve brought your daughter home safe and sound,


With money in her pocket here, a thousand pound:
Take your saucy girl back —Bocking,
again. Essex (Folk-lore Record, iii. pt. ii. 171).

Here comes three knights all out of Spain,


XVIII.
A-courting of your daughter Jane.

My daughter Jane, she is too young,


She can’t abide your flattering tongue.

If she be young, or she be old,


She for her beauty must be sold.

Go back, go back, you Spanish knight,


And rub your spurs till they are bright.

My spurs are bright and richly wrought,


And in this town they were not bought,
And in this town they shan’t be sold,
Neither for silver nor for gold.

Walk up the kitchen and down the hall,


And choose the fairest of us all.

Madams, to you I bow and bend,


I take you for my dearest friend;
You are two beauties, I declare,
So come along with me, my dear.
—Wenlock, Condover, Ellesmere, Market Drayton
(Shropshire Folk-lore, p. 516).

Here come three dukes all out of Spain,


XIX.
In mourning for your daughter Jane.

My daughter Jane, is yet too young


To cast her eyes on such a one.

Let her be young, or let her be old,


’Tis for her beauty she must be sold.
So fare thee well, my lady gay,
I’ll call on you another day.

Turn back, turn back, you saucy Jack,


Up through the kitchen and through the hall,
And pick the fairest of them all.

The fairest one that I can see.


So please, Miss ——, come with me.
—Pembrokeshire, Wales (Folk-lore Record, v. 89).

XX.Here’s two brothers come from Spain,


For to court your daughter Jane.

My daughter Jane, she is too young,


She has not learned her mother tongue.

Be she young, or be she old,


For her beauty she must be sold.

But fare thee well, my lady gay,


And I’ll call back some other day.

Come back! come back! take the fairest you see.

The fairest one that I can see


Is bonnie Jeanie [or Maggie, &c.], so come to me.

Here’s your daughter, safe and sound,


In every pocket a thousand pound,
On every finger a gay gold ring,
So, pray, take your daughter back again.
—People’s Friend, quoted in review of “Arbroath:
Past and Present.”

We are three suitors come from Spain,


XXI.
Come to court your daughter Jane.

My daughter Jane she is too young


To be beguiled by flattering tongue.

Let her be young, or let her be old,


For her beauty she must be sold.

Return, return, your coat is white,


And take the fairest in your sight.

Here’s your daughter safe and sound,


And in her pocket five hundred pound,
On her finger a gay gold ring,
Fit to walk with any king.
—Dublin (Mrs. Lincoln).

Here comes a poor duke out of Spain,


XXII.
He comes to court your daughter Jane.

My daughter Jane is yet too young,


She has a false and flattering tongue.

Let her be young, or let her be old,


Her beauty is gone, she must be sold.

Fare thee well, my lady gay,


I’ll call again another day.
Turn back, turn back, you ugly wight,
And clean your spurs till they shine bright.

My spurs they shine as bright as snow,


And fit for any king to show;
So fare thee well, my lady gay,
I’ll call again another day.

Turn back, turn back, you ugly wight,


And choose the fairest one you like.

The fairest one that I can see,


Is you, dear ——, so come—Notes
with me.
and Queries (1852), vol. vi. 242.

Here comes three knights all out of Spain,


XXIII.
We have come to court your daughter Jane.

Our daughter Jane she is too young,


She has not learned the Spanish tongue.

Whether she be young or old,


’Tis for her beauty she must be sold.

Turn back, turn back, ye Spanish knights,


And rub your spurs till they are bright.

Our spurs are bright and richly wrought,


For in this town they were not bought;
And in this town they shan’t be sold,
Neither for silver nor for gold.

Turn back, turn back, ye Spanish knights,


And brush your buckles till they are bright.

Our buckles are bright and richly wrought,


For in this town they were not bought;
And in this town they shan’t be sold,
Neither for silver nor for gold.
—Yorkshire (Miss E. Cadman).

There was one lord that came from Spain,


XXIV.
He came to court my daughter Jane;

My daughter Jane, she is too young


To be controlled by a flattering tongue.

Will you? No.


Will you? Yes.

[This second one then joins hands with the “lord,” and they dance
round together, saying—]

You dirty wee scut, you wouldn’t come out


To help us with our dancing.
—Ballymiscaw school, co. Down (Miss C. N.
Patterson).

There were one lord came out of Spain,


XXV.
Who came to court your daughter Jane.

Your daughter Jane, she is too young


To be controlled by flattering tongue.

Oh! fare thee well; oh! fare thee well;


I’ll go and court some other girl.

Come back, come back, your coat is white,


And choose the fairest in your sight.

The fairest one that I can see, is ——, come to me.


—Holywood, co. Down (Miss C. N. Patterson).

Here’s two dukes come out from Spain,


XXVI.
For to court your daughter Jane;

My daughter Jane is far too young,


She cannot hear your flattering tongue.

Be she young, or be she old,


Her beauty must be sold,
Either for silver or for gold;
So fare you well, my lady fair,
I’ll call again some other day.
—Galloway (J. G. Carter).

Here’s one old Jew, just come from Spain,


XXVII.
To ask alone your daughter Jane.

Our daughter Jane is far too young


To understand your Spanish tongue.

Go away, Coat-green.

My name is not Coat-green,


I step my foot, and away I go.

Come back, come back, your coat is green,


And choose the fairest one you see.

The fairest one that I can see


Is pretty Alice. Come to me.

I will not come.

Naughty girl, she won’t come out,


She won’t come out, she won’t come out;
Naughty girl, she won’t come out,
To see the ladies dancing.

I will come.

Pretty girl, she has come out,


She has come out, she has come out;
Pretty girl, she has come out,
To see the ladies dancing.
—Berwickshire (A. M. Bell, Antiquary, vol. xxx. p.
15).

Here come two Jews, just come from Spain,


XXVIII.
To take away your daughter Jane.

My daughter Jane is far too young,


She cannot bear your chattering tongue.

Farewell! farewell! we must not stay;


We’ll call again another day.

Come back, come back, your choice is free,


And choose the fairest one you see.

The fairest one that I can see


Is A—— F——. Come to me.
—Cowes, Isle of Wight (Miss E. Smith).

There came three dukes a-riding, a-riding, a-riding,


XXIX.
There came three dukes a-riding,
To court my daughter Jane.

My daughter Jane is far too young, far too young,


My daughter Jane is far too young,
She hath a flattering tongue.

They’re all as red as roses, as roses, as roses,


They’re all as red as roses with sitting in the sun.
—Perth (Rev. W. Gregor).

Here comes a duke a-riding,


XXX.
To court your daughter Jane.

My daughter Jane is far too young


To listen to your saucy tongue;
Go back, go back, you saucy Jack,
And clean your spurs and . . . . . .
My spurs are bright as bright can be,
With a tissima, tissima, tissima tee.

Go through the house, go through the hall,


And choose the fairest of them all.

The fairest one that I can see


Is ——. Come to me. —Clapham School (Mrs. Herbertson).

Here comes three dukes a-riding, a-riding,


XXXI.
Here comes three dukes a-riding, to court your daughter Jane.

My daughter Jane is yet too young


To bear your silly, flattering tongue.

Be she young, or be she old,


She for beauty must and shall be sold.
So fare thee well, my lady gay,
We’ll take our horse and ride away,
And call again another day.

Come back, come back! you Spanish knight,


And clean your spurs, they are not bright.

My spurs are bright as “rickety rock” [and richly wrought],


And in this town they were not bought,
And in this town they shan’t be sold,
Neither for silver, copper, nor gold.
So fare thee well, &c.

Come back! come back! you Spanish Jack [or coxcomb].

Spanish Jack [or coxcomb] is not my name,


I’ll stamp my foot [stamps] and say the same.
So fare thee well, &c.

Come back! come back! you Spanish knight,


And choose the fairest in your sight.

This is the fairest I can see,


So pray, young damsel, walk with me.

We’ve brought your daughter, safe and sound,


And in her pocket a thousand pound,
And on her finger a gay gold ring,
We hope you won’t refuse to take her in.

I’ll take her in with all my heart,


For she and “me” were loth to part.
—Cornwall (Folk-lore Journal, v. 46, 47).

Here comes three dukes all out of Spain,


XXXII.
For to court your daughter Jane.

My daughter Jane, she is too young,


She cannot bear your flattering tongue.

Be she young, or be she old,


For her beauty she must be sold.

So fare thee well, my lady gay,


We’ll call again another day.

Turn back, turn back, you Spanish knight,


And take the fairest in your sight.

Well through the kitchen and through the hall,


I take the fairest of you all.

The fairest one that I can see


Is pretty ——, come to me.
—Gloucestershire (Northall’s Rhymes, p. 385).

Two poor sailors dressed in blue,


XXXIII.
Two poor sailors dressed in blue,
Two poor sailors dressed in blue,
We come for the sake of your daughter Loo.

My daughter Loo, she is too young,


She cannot bear your flattering tongue.

Whether she be young, or whether she be old,


It is our duty, she must be sold.

Take her, take her, the coach is free,


The fairest one that you can see.

The fairest one that we can see,


Is bonnie [ ]. Come to me.

Here’s all your daughters safe and sound,


In every pocket a thousand pound,
On every finger a guinea gold ring,
So please, take one of your daughters in.
—Fochabers, N.E. Scotland (Rev. W. Gregor).

Two poor sailors dressed in blue, dressed in blue, dressed in blue,


XXXIV.
Two poor sailors dressed in blue, come for the sake of your
daughter Loo.

My daughter Loo, she is too young, she is too young, she is too
young,
She cannot bear your flattering tongue.

Let her be young, or yet too old, yet too old, yet too old,
But for her beauty she must be sold.

The haughty thing, she won’t come out, she won’t come out, she
won’t come out;
The haughty thing, she won’t come out,
To help us with our dancing.
Now we have got a beautiful maid, a beautiful maid, a beautiful
maid;
Now we have got a beautiful maid,
To help us with our dancing.
—Nairn (Mrs. Jamieson, through Rev. W. Gregor).

One poor sailor dressed in blue, dressed in blue, dressed in blue,


XXXV.
One poor sailor dressed in blue,
Has come for the sake of your daughter Sue.

My daughter Sue, she is too young,


She cannot bear your flattering tongue.

Whether she be young, or whether she be old,


For her beauty she must be sold.

Take her, take her, the coach is free.

The fairest one that I can see is bonny ( ), come with me.

[No!]

The dirty sclipe, she won’t come out, she won’t come out, she
won’t come out;
The dirty sclipe, she won’t come out to dance along with me.

Now, I have got another poor maid, &c.,


To come along with me.
—Cullen (Rev. W. Gregor).

Here comes two ladies down from Spain,


XXXVI.
A len (?) [all in] French garland.
I’ve come to court your daughter Jane,
And adieu to you, my darling.
—Scotland (Notes and Queries, 3rd series, v.
393).

Here are just three tribes come down from Spain,


XXXVII.
To call upon my sister Jane.
My sister Jane, she is far too young;
I cannot bear her chattering tongue.

The fairest lily that I can see,


Is pretty little Lizzie, will ye come to me?

[No!]

The dirty thing, she won’t come out, she won’t come out, she
won’t come out;
The dirty thing, she won’t come out, to help us with the dancing.

[Yes!]

Now we’ve got a pretty maid, a pretty maid, a pretty maid;


Now we’ve got a pretty maid, to help us with the dancing.
—Waterford (Miss H. E. Harvey).

(b) The players stand in two lines, facing one another, three boys on
one side and the girls (any number) on the other. The boys advance
and retire dancing, and saying the first two lines. The girls stand still,
one who personates a mother answers with the next two lines. The
boys then advance and reply. When they are retiring the mother says
the next lines and the boys reply; they then choose a girl and take
her over to their side. The dialogue is generally spoken, not sung.
The boys turn their toes outwards to show their spurs. The number
of players on the girls’ side is generally an uneven one, the odd one
is the mother and says the dialogue. This is the most general way of
playing, but there are interesting variations. Chambers says two
parties play, one representing a dame and her daughters, the other
the suitors. The suitors move backwards and forwards with their
arms entwined. The mother offers her daughters when she says
“Smell my lilies,” and the game ends by some little childish trick, but
unfortunately, he does not describe this. Miss Ellis (Leicester) says if
the number of players suited, probably all the boys, instead of three,
would be on one side and the girls on the other, but there is no hard
and fast line. They turn out their toes to show their spurs: when they
sing or say, “Pass through the kitchen,” &c., the girls stretch out their
arms, still keeping hold of hand, and the boys, forming a long tail,
wind in and out under their arms as they stand. Having previously
decided among themselves which girl they shall seize, they go up
and down the lines several times, until the period of suspense and
expectation is supposed to have lasted long enough. Then the last
boy in the line puts his arms round the chosen girl’s waist and carries
her off. This goes on until there is only one girl left, who
recommences the game on her part by singing the first lines,
choosing first a boy, who then becomes a Spaniard. In the first
version from Belfast, the first girl who is asked to go refuses, and
another is asked, who consents. In the Manchester version (Miss
Dendy), the girl refuses twice, then accepts. The “mother” is seated
in state with her “daughters” round her in the Bexley Heath (Miss
Morris) version. The two “gentlemen” advance to her and turn
haughtily away when refused. Then they choose a girl and take her
over to their side. In the Shropshire (Edgmond) version, two girls,
one from each end of the line of “daughters,” goes over to the
knights’ side, who also “bow” and “bend” when saying the lines, and
the game is repeated saying five, seven, &c., knights. Here, also, the
last player left on the girls’ side takes the knight’s part in the next
game. Miss Burne adds, at other places the knights call only one girl
by name each time. Both lines in the Shropshire game advance and
retire. In the Dublin game (Mrs. Lincoln), three young boys are
chosen for the suitors, one girl is the mother, and any number from
three to six personate the daughters. The first boy only speaks the
lines. At “Return, return, your coat is white,” he, with the other two
“suitors,” takes the girl, brings her back, and says the last verse.
They then sit down, and the second suitor does the same thing, then
the third one. Then the game is begun again [with three other boys]
until all the daughters have been taken. In the version quoted from
Notes and Queries, two children, mother and daughter, stand on one
side, the other players opposite to them, and advance and retire.
The contributor says they chant the words to a pleasing old melody.
The Yorkshire version (Miss E. Cadman) is played in the usual way,
both sides advancing and retiring in turn, and at the end one of the
“knights” tries to catch one of the girls. They cross the room to each
other’s places. In Co. Down, at Ballymiscaw, Miss Patterson says one
player refuses when asked, and another consents, this one and the
“lord” then join hands and dance round together, saying the last
words. The Annaverna version is sung by one on each side—“king
and the mother.” The Berwickshire game was played by six children,
one on one side, five on the other. The first lines are sung on both
sides; then the rest is dialogue until the girl refuses, when the “Jew”
dances round by himself, singing the words; she then consents, and
the two dance round with joined hands as in a reel, singing the last
verse. The dialogue is spoken with animation, and the “Jew steps his
foot” and prances away when saying these words. Twelve children in
the Perth version stand in a row, another stands a little in advance,
who is called “daughter Jane,” another is the “mother.” Three more
stand in front of the twelve and are the “Dukes.” These dance
forwards and backwards before “Jane and her mother,” singing the
first lines. The mother answers. When they sing the last line the
“Dukes” choose one of the twelve, and sing the words over again
until all the twelve are on the “Dukes’” side. Then they try to carry
off “Jane” and the “mother,” and run until they are caught. In the
Clapham school version (Mrs. Herbertson), the “Duke” tries to drag
by force the chosen girl across a handkerchief or other boundary, if
successful she goes on his side. In the Cornwall version the “Dukes”
retire and consult before choosing a girl, then select one. When all
have been taken they bring them back in the same order to the
“mother,” saying the last verse, and the “mother” replies in the last
two lines. In the London version, the “Dukes” take the girl and rob
her, then bring her back. In the Fochabers version (Rev. W. Gregor),
the two “sailors” join hands crosswise, walk backwards and forwards,
and sing the words. The girl crosses over to them when chosen.
When all are chosen the “sailors” bring all the girls before the
mother, singing the last verse. The mother searches the daughters
one after the other, finding neither money nor ring. She then chases
the sailors, and the one caught becomes mother next game.
(c) This game has been said by previous collectors, and at first sight
may be thought to be merely a variant of “Three Dukes,” but it will
on investigation, I think, prove to be more than this. In the first
place, the obvious borrowing from the “Three Dukes” of a few
words, as in versions Nos. 29, 30, and 31, tells against the theory of
identity of the two games. Then the form of marriage custom is
different, though it is still marriage under primitive conditions of
society. The personal element, entirely absent from the “Three
Dukes,” is here one of the principal characteristics. The marriage is
still one without previous courtship or love between two individuals,
but the parental element is present here, or at any rate that of some
authority, and a sanction is given, although there is no trace of any
actual ceremony. The young men, or suitors, apparently desire a
particular person in marriage, and although there is no wooing of
that person a demand is made for her. These suitors are, I think,
making the demand on the part of another rather than for
themselves. They are the ambassadors or friends of the would-be
bridegrooms, and are soliciting for a marriage in which purchase
money or dowry is to be paid. The mention of “gold and silver” in
many versions, and the line, “she must be sold,” is important.
All these indications of purchase refer to a time when the custom of
offering gold, money, or other valuables for a bride was in vogue.
While, therefore, the game has traces of carrying off the bride, this
carrying off is in strict accord with the conditions prevalent when
marriage by purchase had succeeded to marriage by capture. The
bargaining spirit is not much “en evidence” in this game, not, that is
to say, in the same sense as is shown in “Three Sailors,” p. 282, but
there is sufficient evidence of a mercantile spirit to prove that
women and girls were too valuable to be parted with by their own
tribe or family without something deemed equivalent being given in
return. There is a desire shown to possess the girl for her beauty;
and that a choice of a suitor could or would be made is shown by the
remarks that she is too young and does not know the language and
customs of this suitor.
The mention of the spurs conveys the suggestion that the suitors or
ambassadors are men of quality and renown. To win their spurs was
an object greatly desired by all young men. Their reply to the taunt
that their spurs are “dull” may mean that they are not bright from
use, and may also show the idea that these men have come on a
journey from some distance for a bride or brides, and this only is
responsible for their spurs not being as bright as usual. Again, being
“richly wrought” is probably an indication of wealth or consequence.
Mention must be made of the mead not being made nor the cake yet
baked, which occurs in two versions. If these two versions can be
considered old ones, this would tend to show evidence of the
ceremony of the eating together of particular food, which forms the
most important element in primitive marriage ceremonies.
There occurs in some versions the incident of asking the girl to
come, and the dancing round when she consents, mostly in
connection with the incident of invitation to dance. This may not
therefore belong, and I do not think it does, to the early forms of
this game; but we must remember that dancing formed a part of the
marriage ceremonies down to quite a late date, and it is therefore
not surprising it should be found in many versions.
It has been suggested that this game has for its origin an historical
event in the reign of Edward III., whose daughter Jane married a
prince of Spain. There is some possibility in this, as doubtless the
marriage was conducted by ambassadors first of all with pomp and
ceremonial, but I think the game really dates from a much earlier
period, and if there are any grounds for connecting it with this
particular royal marriage, it may merely have altered and fixed some
of the words, such as “daughter Jane,” “Lords from Spain,” “Spanish
gold,” in people’s minds, and in this way tended to preserve the
game in its modern form.
Mr. Addy, in his Sheffield Glossary, considers that the mention of the
three knights and gifts of gold is a fragment of some old pageant of
the Three Kings of Cologne, who, according to ancient legend,
brought gifts to the infant Jesus, but I can see no evidence of this.
It is somewhat curious that this game is very rarely sung to a tune,
nor have I succeeded in obtaining one. It is usually said to a sort of
sing-song chant, or else it is spoken in dialogue, and that with a
good deal of animation.
Mr. Newell gives versions, as played in America, similar to many here
given, and Mr. Northall (Folk Rhymes, p. 385) gives one from
Gloucestershire and Warwickshire.[Addendum]

[10] Incomplete, there is more of the game, but the maid could not remember it.
[11] Probably once “boy,” pronounced “by” in Essex.

Three Little Ships


[Play]

—London (A. B. Gomme).

[Play]
—Rimbault’s Nursery Rhymes.

I. Three little ships come sailing by,


Sailing by, sailing by;
Three little ships come sailing by,
New Year’s day in the morning.

Who do you think was in the ships,


In the ships, in the ships;
Who do you think was in the ships,
New Year’s day in the morning?

Three pretty girls were in the ships,


In the ships, in the ships;
Three pretty girls were in the ships,
New Year’s day in the morning.

One could whistle, and one could sing,


One could play on the violin;
One could whistle, and one could sing,
New Year’s day in the morning.
—London (A. B. Gomme).

II.I saw three ships come sailing by,


Come sailing by, come sailing by;
I saw three ships come sailing by
On New Year’s day in the morning.

And what do you think was in them then,


In them then, in them then;
And what do you think was in them then,
Welcome to our website – the ideal destination for book lovers and
knowledge seekers. With a mission to inspire endlessly, we offer a
vast collection of books, ranging from classic literary works to
specialized publications, self-development books, and children's
literature. Each book is a new journey of discovery, expanding
knowledge and enriching the soul of the reade

Our website is not just a platform for buying books, but a bridge
connecting readers to the timeless values of culture and wisdom. With
an elegant, user-friendly interface and an intelligent search system,
we are committed to providing a quick and convenient shopping
experience. Additionally, our special promotions and home delivery
services ensure that you save time and fully enjoy the joy of reading.

Let us accompany you on the journey of exploring knowledge and


personal growth!

ebookname.com

You might also like