Home > Store

Microsoft Visual C# Step by Step, 8th Edition

Register your product to gain access to bonus material or receive a coupon.

Microsoft Visual C# Step by Step, 8th Edition

eBook (Watermarked)

  • Sorry, this book is no longer in print.
  • Includes EPUB and PDF
  • About eBook Formats
  • This eBook includes the following formats, accessible from your Account page after purchase:

    ePub EPUB The open industry format known for its reflowable content and usability on supported mobile devices.

    Adobe Reader PDF The popular standard, used most often with the free Adobe® Reader® software.

    This eBook requires no passwords or activation to read. We customize your eBook by discreetly watermarking it with your name, making it uniquely yours.

Not for Sale

Description

  • Copyright 2016
  • Dimensions: 7-3/8" x 9"
  • Edition: 8th
  • eBook (Watermarked)
  • ISBN-10: 1-5093-0108-9
  • ISBN-13: 978-1-5093-0108-9

Your hands-on guide to Microsoft Visual C# fundamentals with Visual Studio 2015
Expand your expertise--and teach yourself the fundamentals of programming with the latest version of Visual C# with Visual Studio 2015. If you are an experienced software developer, you’ll get all the guidance, exercises, and code you need to start building responsive, scalable Windows 10 and Universal Windows Platform applications with Visual C#.

Discover how to:

  • Quickly start creating Visual C# code and projects with Visual Studio 2015
  • Work with variables, operators, expressions, and methods
  • Control program flow with decision and iteration statements
  • Build more robust apps with error, exception, and resource management
  • Master the essentials of Visual C# object-oriented programming
  • Use enumerations, structures, generics, collections, indexers, and other advanced features
  • Create in-memory data queries with LINQ query expressions
  • Improve application throughput and response time with asynchronous methods
  • Decouple application logic and event handling
  • Streamline development with new app templates
  • Implement the Model-View-ViewModel (MVVM) pattern
  • Build Universal Windows Platform apps that smoothly adapt to PCs, tablets, and Windows phones
  • Integrate Microsoft Azure cloud databases and RESTful web services
About You
  • For software developers who are new to Visual C# or who are upgrading from older versions
  • Readers should have experience with at least one programming language
  • No prior Microsoft .NET or Visual Studio development experience required

Sample Content

Table of Contents

Introduction     xix
PART I: INTRODUCING MICROSOFT VISUAL C# AND MICROSOFT VISUAL STUDIO 2015      
Chapter 1: Welcome to C#     3

Beginning programming with the Visual Studio 2015 environment     3
Writing your first program     8
Using namespaces     14
Creating a graphical application     17
Examining the Universal Windows Platform app     26
Adding code to the graphical application     29
Summary     32
Quick Reference     32
Chapter 2: Working with variables, operators, and expressions     33
Understanding statements     33
Using identifiers     34
Identifying keywords     34
Using variables     36
Naming variables     36
Declaring variables     37
Working with primitive data types     37
Unassigned local variables     38
Displaying primitive data type values     38
Using arithmetic operators     45
Operators and types     45
Examining arithmetic operators     47
Controlling precedence     52
Using associativity to evaluate expressions     53
Associativity and the assignment operator     53
Incrementing and decrementing variables     54
Prefix and postfix     55
Declaring implicitly typed local variables     56
Summary     57
Quick Reference     58
Chapter 3: Writing methods and applying scope     59
Creating methods     59
Declaring a method     60
Returning data from a method     61
Using expression-bodied methods     62
Calling methods     63
Applying scope     66
Defining local scope     66
Defining class scope     67
Overloading methods     68
Writing methods     68
Using optional parameters and named arguments     77
Defining optional parameters     79
Passing named arguments     79
Resolving ambiguities with optional parameters and named arguments     80
Summary     85
Quick reference     86
Chapter 4: Using decision statements     87
Declaring Boolean variables     87
Using Boolean operators     88
Understanding equality and relational operators     88
Understanding conditional logical operators     89
Short circuiting     90
Summarizing operator precedence and associativity     90
Using if statements to make decisions     91
Understanding if statement syntax     91
Using blocks to group statements     93
Cascading if statements     94
Using switch statements     99
Understanding switch statement syntax     100
Following the switch statement rules     101
Summary     104
Quick reference     105
Chapter 5: Using compound assignment and iteration statements     107
Using compound assignment operators     107
Writing while statements     108
Writing for statements     114
Understanding for statement scope     115
Writing do statements     116
Summary     125
Quick reference     125
Chapter 6: Managing errors and exceptions     127
Coping with errors     127
Trying code and catching exceptions     128
Unhandled exceptions     129
Using multiple catch handlers     130
Catching multiple exceptions     131
Propagating exceptions     136
Using checked and unchecked integer arithmetic     138
Writing checked statements     139
Writing checked expressions     140
Throwing exceptions     143
Using a finally block     148
Summary     149
Quick reference     150
PART II: UNDERSTANDING THE C# OBJECT MODEL
Chapter 7: Creating and managing classes and objects     153

Understanding classification     153
The purpose of encapsulation     154
Defining and using a class     154
Controlling accessibility     156
Working with constructors     157
Overloading constructors     158
Understanding static methods and data     167
Creating a shared field     168
Creating a static field by using the const keyword     169
Understanding static classes     169
Static using statements     170
Anonymous classes     172
Summary     174
Quick reference     174
Chapter 8: Understanding values and references     177
Copying value type variables and classes     177
Understanding null values and nullable types     183
Using nullable types     185
Understanding the properties of nullable types     186
Using ref and out parameters     187
Creating ref parameters     188
Creating out parameters     188
How computer memory is organized     190
Using the stack and the heap     192
The System.Object class     193
Boxing     194
Unboxing     194
Casting data safely     196
The is operator     196
The as operator     197
Summary     199
Quick reference     199
Chapter 9: Creating value types with enumerations
and structures     201
Working with enumerations     201
Declaring an enumeration     202
Using an enumeration     202
Choosing enumeration literal values     203
Choosing an enumeration’s underlying type     204
Working with structures     206
Declaring a structure     208
Understanding differences between structures and classes     209
Declaring structure variables     210
Understanding structure initialization     211
Copying structure variables     215
Summary     219
Quick reference     219
Chapter 10: Using arrays     221
Declaring and creating an array     221
Declaring array variables     221
Creating an array instance     222
Populating and using an array     223
Creating an implicitly typed array     224
Accessing an individual array element     225
Iterating through an array     225
Passing arrays as parameters and return values for a method    227
Copying arrays     228
Using multidimensional arrays     230
Creating jagged arrays     231
Summary     241
Quick reference     242
Chapter 11: Understanding parameter arrays     243
Overloading—a recap     243
Using array arguments     244
Declaring a params array     245
Using params object[ ]     247
Using a params array     249
Comparing parameter arrays and optional parameters     252
Summary     254
Quick reference     254
Chapter 12: Working with inheritance     255
What is inheritance?     255
Using inheritance     256
The System.Object class revisited     258
Calling base-class constructors     258
Assigning classes     259
Declaring new methods     261
Declaring virtual methods     262
Declaring override methods     263
Understanding protected access     265
Understanding extension methods     271
Summary     275
Quick reference     276
Chapter 13: Creating interfaces and defining abstract classes     277
Understanding interfaces     277
Defining an interface     278
Implementing an interface     279
Referencing a class through its interface     280
Working with multiple interfaces     281
Explicitly implementing an interface     282
Interface restrictions     283
Defining and using interfaces     284
Abstract classes     293
Abstract methods     295
Sealed classes     295
Sealed methods     295
Implementing and using an abstract class     296
Summary     302
Quick reference     303
Chapter 14: Using garbage collection and resource management 305
The life and times of an object     305
Writing destructors     306
Why use the garbage collector?     308
How does the garbage collector work?     310
Recommendations     310
Resource management     311
Disposal methods     311
Exception-safe disposal     312
The using statement and the IDisposable interface     312
Calling the Dispose method from a destructor     314
Implementing exception-safe disposal     316
Summary     325
Quick reference     325
PART III: DEFINING EXTENSIBLE TYPES WITH C#
Chapter 15: Implementing properties to access fields     329

Implementing encapsulation by using methods     329
What are properties?     331
Using properties     333
Read-only properties     334
Write-only properties     334
Property accessibility     335
Understanding the property restrictions     336
Declaring interface properties     337
Replacing methods with properties     339
Generating automatic properties     343
Initializing objects by using properties     345
Summary     349
Quick reference     350
Chapter 16: Using indexers     353
What is an indexer?     353
An example that doesn’t use indexers     353
The same example using indexers     355
Understanding indexer accessors     357
Comparing indexers and arrays     358
Indexers in interfaces     360
Using indexers in a Windows application     361
Summary     367
Quick reference     368
Chapter 17: Introducing generics     369
The problem with the object type     369
The generics solution     373
Generics vs. generalized classes     375
Generics and constraints     375
Creating a generic class     376
The theory of binary trees     376
Building a binary tree class by using generics     379
Creating a generic method     389
Defining a generic method to build a binary tree     389
Variance and generic interfaces     391
Covariant interfaces     393
Contravariant interfaces     395
Summary     397
Quick reference     397
Chapter 18: Using collections     399
What are collection classes?     399
The List<T> collection class     401
The LinkedList<T> collection class     403
The Queue<T> collection class     404
The Stack<T> collection class     405
The Dictionary<TKey, TValue> collection class     407
The SortedList<TKey, TValue> collection class     408
The HashSet<T> collection class     409
Using collection initializers     411
The Find methods, predicates, and lambda expressions     411
The forms of lambda expressions     413
Comparing arrays and collections     415
Using collection classes to play cards     416
Summary     420
Quick reference     420
Chapter 19: Enumerating collections     423
Enumerating the elements in a collection     423
Manually implementing an enumerator     425
Implementing the IEnumerable interface     429
Implementing an enumerator by using an iterator     431
A simple iterator     432
Defining an enumerator for the Tree<TItem> class by using an iterator     434
Summary     436
Quick reference     437
Chapter 20: Decoupling application logic and handling events     439
Understanding delegates     440
Examples of delegates in the .NET Framework class library     441
The automated factory scenario     443
Implementing the factory control system without using delegates     443
Implementing the factory by using a delegate     444
Declaring and using delegates     447
Lambda expressions and delegates     455
Creating a method adapter     455
Enabling notifications by using events     456
Declaring an event     456
Subscribing to an event     457
Unsubscribing from an event     457
Raising an event     458
Understanding user interface events     458
Using events     460
Summary     466
Quick reference     466
Chapter 21: Querying in-memory data by using query expressions     469
What is LINQ?     469
Using LINQ in a C# application     470
Selecting data     472
Filtering data     474
Ordering, grouping, and aggregating data     475
Joining data     477
Using query operators     479
Querying data in Tree<TItem> objects     481
LINQ and deferred evaluation     487
Summary     491
Quick reference     491
Chapter 22: Operator overloading     493
Understanding operators     493
Operator constraints     494
Overloaded operators     494
Creating symmetric operators     496
Understanding compound assignment evaluation     498
Declaring increment and decrement operators     499
Comparing operators in structures and classes     500
Defining operator pairs     500
Implementing operators     501
Understanding conversion operators     508
Providing built-in conversions     508
Implementing user-defined conversion operators     509
Creating symmetric operators, revisited     510
Writing conversion operators     511
Summary     513
Quick reference     514
PART IV: BUILDING UNIVERSAL WINDOWS PLATFORM APPLICATIONS WITH C#      
Chapter 23: Improving throughput by using tasks     517

Why perform multitasking by using parallel processing?     517
The rise of the multicore processor     518
Implementing multitasking by using the Microsoft .NET Framework     519
Tasks, threads, and the ThreadPool     520
Creating, running, and controlling tasks     521
Using the Task class to implement parallelism     524
Abstracting tasks by using the Parallel class     536
When not to use the Parallel class     541
Canceling tasks and handling exceptions     543
The mechanics of cooperative cancellation     543
Using continuations with canceled and faulted tasks     556
Summary     557
Quick reference     557
Chapter 24: Improving response time by performing
asynchronous operations     559
Implementing asynchronous methods     560
Defining asynchronous methods: The problem     560
Defining asynchronous methods: The solution     564
Defining asynchronous methods that return values     569
Asynchronous method gotchas     570
Asynchronous methods and the Windows Runtime APIs     572
Using PLINQ to parallelize declarative data access     575
Using PLINQ to improve performance while iterating through a collection     576
Canceling a PLINQ query     580
Synchronizing concurrent access to data     581
Locking data     584
Synchronization primitives for coordinating tasks     584
Canceling synchronization     587
The concurrent collection classes     587
Using a concurrent collection and a lock to implement thread-safe data access     588
Summary     598
Quick reference     599
Chapter 25: Implementing the user interface for a Universal Windows Platform app     601
Features of a Universal Windows Platform app     602
Using the Blank App template to build a Universal Windows Platform app     605
Implementing a scalable user interface     607
Applying styles to a UI     638
Summary     649
Quick reference     649
Chapter 26: Displaying and searching for data in a Universal Windows Platform app     651
Implementing the Model-View-ViewModel pattern     651
Displaying data by using data binding     652
Modifying data by using data binding     659
Using data binding with a ComboBox control     663
Creating a ViewModel     665
Adding commands to a ViewModel     669
Searching for data using Cortana     680
Providing a vocal response to voice commands     692
Summary     695
Quick reference     696
Chapter 27: Accessing a remote database from a Universal Windows Platform app     697
Retrieving data from a database     698
Creating an entity model     703
Creating and using a REST web service     712
Inserting, updating, and deleting data through a REST web service     728
Reporting errors and updating the UI     738
Summary     746
Quick reference     747
Index     749

Updates

Submit Errata

More Information

InformIT Promotional Mailings & Special Offers

I would like to receive exclusive offers and hear about products from InformIT and its family of brands. I can unsubscribe at any time.

Overview


Pearson Education, Inc., 221 River Street, Hoboken, New Jersey 07030, (Pearson) presents this site to provide information about products and services that can be purchased through this site.

This privacy notice provides an overview of our commitment to privacy and describes how we collect, protect, use and share personal information collected through this site. Please note that other Pearson websites and online products and services have their own separate privacy policies.

Collection and Use of Information


To conduct business and deliver products and services, Pearson collects and uses personal information in several ways in connection with this site, including:

Questions and Inquiries

For inquiries and questions, we collect the inquiry or question, together with name, contact details (email address, phone number and mailing address) and any other additional information voluntarily submitted to us through a Contact Us form or an email. We use this information to address the inquiry and respond to the question.

Online Store

For orders and purchases placed through our online store on this site, we collect order details, name, institution name and address (if applicable), email address, phone number, shipping and billing addresses, credit/debit card information, shipping options and any instructions. We use this information to complete transactions, fulfill orders, communicate with individuals placing orders or visiting the online store, and for related purposes.

Surveys

Pearson may offer opportunities to provide feedback or participate in surveys, including surveys evaluating Pearson products, services or sites. Participation is voluntary. Pearson collects information requested in the survey questions and uses the information to evaluate, support, maintain and improve products, services or sites, develop new products and services, conduct educational research and for other purposes specified in the survey.

Contests and Drawings

Occasionally, we may sponsor a contest or drawing. Participation is optional. Pearson collects name, contact information and other information specified on the entry form for the contest or drawing to conduct the contest or drawing. Pearson may collect additional personal information from the winners of a contest or drawing in order to award the prize and for tax reporting purposes, as required by law.

Newsletters

If you have elected to receive email newsletters or promotional mailings and special offers but want to unsubscribe, simply email information@informit.com.

Service Announcements

On rare occasions it is necessary to send out a strictly service related announcement. For instance, if our service is temporarily suspended for maintenance we might send users an email. Generally, users may not opt-out of these communications, though they can deactivate their account information. However, these communications are not promotional in nature.

Customer Service

We communicate with users on a regular basis to provide requested services and in regard to issues relating to their account we reply via email or phone in accordance with the users' wishes when a user submits their information through our Contact Us form.

Other Collection and Use of Information


Application and System Logs

Pearson automatically collects log data to help ensure the delivery, availability and security of this site. Log data may include technical information about how a user or visitor connected to this site, such as browser type, type of computer/device, operating system, internet service provider and IP address. We use this information for support purposes and to monitor the health of the site, identify problems, improve service, detect unauthorized access and fraudulent activity, prevent and respond to security incidents and appropriately scale computing resources.

Web Analytics

Pearson may use third party web trend analytical services, including Google Analytics, to collect visitor information, such as IP addresses, browser types, referring pages, pages visited and time spent on a particular site. While these analytical services collect and report information on an anonymous basis, they may use cookies to gather web trend information. The information gathered may enable Pearson (but not the third party web trend services) to link information with application and system log data. Pearson uses this information for system administration and to identify problems, improve service, detect unauthorized access and fraudulent activity, prevent and respond to security incidents, appropriately scale computing resources and otherwise support and deliver this site and its services.

Cookies and Related Technologies

This site uses cookies and similar technologies to personalize content, measure traffic patterns, control security, track use and access of information on this site, and provide interest-based messages and advertising. Users can manage and block the use of cookies through their browser. Disabling or blocking certain cookies may limit the functionality of this site.

Do Not Track

This site currently does not respond to Do Not Track signals.

Security


Pearson uses appropriate physical, administrative and technical security measures to protect personal information from unauthorized access, use and disclosure.

Children


This site is not directed to children under the age of 13.

Marketing


Pearson may send or direct marketing communications to users, provided that

  • Pearson will not use personal information collected or processed as a K-12 school service provider for the purpose of directed or targeted advertising.
  • Such marketing is consistent with applicable law and Pearson's legal obligations.
  • Pearson will not knowingly direct or send marketing communications to an individual who has expressed a preference not to receive marketing.
  • Where required by applicable law, express or implied consent to marketing exists and has not been withdrawn.

Pearson may provide personal information to a third party service provider on a restricted basis to provide marketing solely on behalf of Pearson or an affiliate or customer for whom Pearson is a service provider. Marketing preferences may be changed at any time.

Correcting/Updating Personal Information


If a user's personally identifiable information changes (such as your postal address or email address), we provide a way to correct or update that user's personal data provided to us. This can be done on the Account page. If a user no longer desires our service and desires to delete his or her account, please contact us at customer-service@informit.com and we will process the deletion of a user's account.

Choice/Opt-out


Users can always make an informed choice as to whether they should proceed with certain services offered by InformIT. If you choose to remove yourself from our mailing list(s) simply visit the following page and uncheck any communication you no longer want to receive: www.informit.com/u.aspx.

Sale of Personal Information


Pearson does not rent or sell personal information in exchange for any payment of money.

While Pearson does not sell personal information, as defined in Nevada law, Nevada residents may email a request for no sale of their personal information to NevadaDesignatedRequest@pearson.com.

Supplemental Privacy Statement for California Residents


California residents should read our Supplemental privacy statement for California residents in conjunction with this Privacy Notice. The Supplemental privacy statement for California residents explains Pearson's commitment to comply with California law and applies to personal information of California residents collected in connection with this site and the Services.

Sharing and Disclosure


Pearson may disclose personal information, as follows:

  • As required by law.
  • With the consent of the individual (or their parent, if the individual is a minor)
  • In response to a subpoena, court order or legal process, to the extent permitted or required by law
  • To protect the security and safety of individuals, data, assets and systems, consistent with applicable law
  • In connection the sale, joint venture or other transfer of some or all of its company or assets, subject to the provisions of this Privacy Notice
  • To investigate or address actual or suspected fraud or other illegal activities
  • To exercise its legal rights, including enforcement of the Terms of Use for this site or another contract
  • To affiliated Pearson companies and other companies and organizations who perform work for Pearson and are obligated to protect the privacy of personal information consistent with this Privacy Notice
  • To a school, organization, company or government agency, where Pearson collects or processes the personal information in a school setting or on behalf of such organization, company or government agency.

Links


This web site contains links to other sites. Please be aware that we are not responsible for the privacy practices of such other sites. We encourage our users to be aware when they leave our site and to read the privacy statements of each and every web site that collects Personal Information. This privacy statement applies solely to information collected by this web site.

Requests and Contact


Please contact us about this Privacy Notice or if you have any requests or questions relating to the privacy of your personal information.

Changes to this Privacy Notice


We may revise this Privacy Notice through an updated posting. We will identify the effective date of the revision in the posting. Often, updates are made to provide greater clarity or to comply with changes in regulatory requirements. If the updates involve material changes to the collection, protection, use or disclosure of Personal Information, Pearson will provide notice of the change through a conspicuous notice on this site or other appropriate way. Continued use of the site after the effective date of a posted revision evidences acceptance. Please contact us if you have questions or concerns about the Privacy Notice or any objection to any revisions.

Last Update: November 17, 2020