Starting Out with Visual C#
Fifth Edition
Tony Gaddis
Haywood Community College
Senior Vice President Courseware Portfolio Management: Marcia J. Horton
Director, Portfolio Management: Engineering, Computer Science & Global Editions: Julian Partridge
Portfolio Manager: Matt Goldstein
Portfolio Management Assistant: Meghan Jacoby
Managing Content Producer: Scott Disanno
Content Producer: Carole Snyder
Rights and Permissions Manager: Ben Ferrini
Manufacturing Buyer, Higher Ed, Lake Side Communications, Inc. (LSC): Maura Zaldivar-Garcia
Inventory Manager: Bruce Boundy
Product Marketing Manager: Yvonne Vannatta
Field Marketing Manager: Demetrius Hall
Marketing Assistant: Jon Bryant
Cover Designer: Integra
Cover Photo: Akepong Srichaichana /Shutterstock
Printer/Binder: LSC Communications, Inc.
Full-Service Project Management: Abhishan Sharma, Integra
Copyright 2020 by Pearson Education, Inc. or its affiliates. All Rights Reserved. Printed in the United States of America. This publication is protected by copyright, and permission should be obtained from the publisher prior to any prohibited reproduction, storage in a retrieval system, or transmission in any form or by any means, electronic, mechanical, photocopying, recording, or otherwise. For information regarding permissions, request forms and the appropriate contacts within the Pearson Education Global Rights & Permissions department, please visit www.pearsoned.com/permissions.
Acknowledgements of third party content appear the same page as the content, which constitutes an extension of this copyright page. Unless otherwise indicated herein, any third-party trademarks that may appear in this work are the property of their respective owners and any references to third-party trademarks, logos or other trade dress are for demonstrative or descriptive purposes only. Such references are not intended to imply any sponsorship, endorsement, authorization, or promotion of Pearsons products by the owners of such marks, or any relationship between the owner and Pearson Education, Inc. or its affiliates, authors, licensees or distributors.
The programs and applications presented in this book have been included for their instructional value. They have been tested with care, but are not guaranteed for any particular purpose. The publisher does not offer any warranties or representations, nor does it accept any liabilities with respect to the programs or applications.
Library of Congress Cataloging-in-Publication Data
Names: Gaddis, Tony, author.
Title: Starting out with visual C# / Tony Gaddis, Haywood Community College.
Description: Fifth edition. | Hoboken, NJ : Pearson, [2020] | Includes index.
Identifiers: LCCN 2018048218 | ISBN 9780135183519 | ISBN 0135183510
Subjects: LCSH: C# (Computer program language) | Visual programming languages (Computer science)
Classification: LCC QA76.73.C154 G33 2019 | DDC 005.1/18--dc23 LC record available at https://lccn.loc.gov/2018048218
ISBN 10: 0-13-518351-0
ISBN 13: 978-0-13-518351-9
10 9 8 7 6 5 4 3 2 1
Locations of VideoNotes www.pearson.com/cs-resources
Brief Contents
Contents
Preface
Welcome to Starting Out with Visual C#, Fifth Edition. This book is intended for an introductory programming course and is ideal for students with no prior experience. Students who are new to programming will appreciate the clear, down-to-earth explanations and the detailed walk-throughs that are provided by the hands-on tutorials. More experienced students will appreciate the depth of detail as they learn about the .NET Framework, databases, Language-Integrated Query, and other topics.
As with all the books in the Starting Out With series, the hallmark of this text is its clear, friendly, and easy-to-understand writing. In addition, it is rich in example programs that are concise and practical. The programs in this book include short examples that highlight specific programming topics, as well as more involved examples that focus on problem solving. Each chapter provides numerous hands-on tutorials that guide the student through each step of the development of an application. In addition to detailed, step-by-step instructions, the tutorials also provide the applications completed code and screen captures of the completed forms.
New to This Edition
The biggest changes in this edition appear in the last half of the book. Some of the chapters have been reorganized, and two new chapters have been added. Here is a summary of the reorganization:
The ImageList control is now covered along with Arrays and Lists in . Since an ImageList is a collection of images, it is fitting that this control be covered in the same chapter as Arrays and Lists.
is titled Structures, Enumerated Types, and Dictionaries.
Two new chapters have been added. In this edition, is titled Language-Integrated Query (LINQ).
An abundance of new topics and improvements has been added to this edition:
var
Keyword: This edition introduces the var
keyword for variable declaration.
Advanced String Formatting: includes a new section on formatting strings with the String.Format
method.
Working with Dates and Times: includes a new section about working with dates and times. The section covers the DateTime
and TimeSpan
data types, as well as the DateTimePicker control.
Dictionaries: includes a new section on the Dictionary
collection. The student learns to store and work with data as keyvalue pairs in dictionaries.
More Use of Auto-Properties: In the previous editions, property declarations were almost always written with explicitly declared backing fields, even when the properties were simply used to set and get a value. Where possible, those property declarations have been rewritten as auto-properties.
Object Initializer Syntax: Object initializer syntax is introduced in as an alternative way to declare and initialize structures and class instances.
Static Members: has a new section on static fields, properties, methods, and classes.
Sealed Classes and Methods: has a new discussion on using the sealed
keyword to prevent classes from being inherited from, and to prevent methods from being overridden.
Extension Methods: covers extension methods, which allow you to extend classes that you cannot inherit from, as well as the primitive data types.
Interfaces: now includes a section on writing and using interfaces.
Delegates: introduces the student to delegates.
Anonymous Methods: also introduces anonymous methods, which go hand-in-hand with delegates.
Lambda Expressions: concludes by showing the student how to use a lambda expression to concisely create a delegate and anonymous method.
Language-Integrated Query (LINQ): introduces LINQ, and shows how to query simple data structures such as arrays and Lists using LINQ to Objects , and how to query databases using LINQ to SQL .
Next page