Microsoft Visual C# Step by Step, 9th Edition PDF.pdf

This document was uploaded by one of our users. The uploader already confirmed that they had the permission to publish it. If you are author/publisher or own the copyright of this documents, please report to us by using this DMCA report form.

Simply click on the Download Book button.

Yes, Book downloads on Ebookily are 100% Free.

Sometimes the book is free on Amazon As well, so go ahead and hit "Search on Amazon"

John Sharp is a principal technologist for CM Group Ltd, a software development and consultancy company in the United Kingdom. He is well versed as a software consultant, developer, author, and trainer, with more than 35 years of experience, ranging from Pascal programming on CP/M and C/Oracle application development on various flavors of UNIX to the design of C# and JavaScript distributed applications and development on Windows 10 and Microsoft Azure. He also spends much of his time writing courseware for Microsoft, focusing on areas such as Data Science using R and Python, Big Data processing with Spark and CosmosDB, and scalable application architecture with Azure.

Author(s): John Sharp
Edition: 9th Edition
Year: 2018

Pages: 1515
Tags: C#, John Sharp, Microsoft

Title Page......Page 2
Copyright Page......Page 4
Contents at a Glance......Page 17
Contents......Page 19
Acknowledgments......Page 33
About the Author......Page 35
Introduction......Page 36
PART I INTRODUCING MICROSOFT VISUAL C# AND MICROSOFT VISUAL STUDIO 2017......Page 50
Beginning programming with the Visual Studio 2017 environment......Page 51
Writing your first program......Page 57
Using namespaces......Page 66
Creating a graphical application......Page 71
Examining the Universal Windows Platform app......Page 83
Adding code to the graphical application......Page 88
Quick reference......Page 92
Understanding statements......Page 94
Using identifiers......Page 95
Identifying keywords......Page 96
Using variables......Page 97
Declaring variables......Page 98
Specifying numeric values......Page 99
Working with primitive data types......Page 100
Unassigned local variables......Page 101
Displaying primitive data type values......Page 102
Using arithmetic operators......Page 110
Operators and types......Page 111
Examining arithmetic operators......Page 114
Controlling precedence......Page 120
Associativity and the assignment operator......Page 121
Prefix and postfix......Page 123
Declaring implicitly typed local variables......Page 124
Quick reference......Page 126
Creating methods......Page 128
Declaring a method......Page 129
Returning data from a method......Page 131
Using expression-bodied methods......Page 132
Specifying the method call syntax......Page 134
Returning multiple values from a method......Page 138
Applying scope......Page 141
Defining local scope......Page 142
Defining class scope......Page 143
Overloading methods......Page 144
Writing methods......Page 145
Refactoring code......Page 152
Nesting methods......Page 157
Using optional parameters and named arguments......Page 161
Defining optional parameters......Page 163
Passing named arguments......Page 164
Resolving ambiguities with optional parameters and named arguments......Page 165
Quick reference......Page 172
Chapter 4 Using decision statements......Page 175
Using Boolean operators......Page 176
Understanding conditional logical operators......Page 177
Summarizing operator precedence and associativity......Page 179
Understanding if statement syntax......Page 181
Using blocks to group statements......Page 183
Cascading if statements......Page 184
Using switch statements......Page 191
Understanding switch statement syntax......Page 192
Following the switch statement rules......Page 193
Quick reference......Page 198
Using compound assignment operators......Page 201
Writing while statements......Page 203
Writing for statements......Page 210
Understanding for statement scope......Page 212
Writing do statements......Page 213
Quick reference......Page 223
Chapter 6 Managing errors and exceptions......Page 225
Trying code and catching exceptions......Page 226
Unhandled exceptions......Page 228
Using multiple catch handlers......Page 229
Catching multiple exceptions......Page 230
Filtering exceptions......Page 232
Propagating exceptions......Page 238
Using checked and unchecked integer arithmetic......Page 240
Writing checked statements......Page 241
Writing checked expressions......Page 242
Throwing exceptions......Page 246
Using throw exceptions......Page 252
Using a finally block......Page 253
Summary......Page 254
Quick reference......Page 255
PART II UNDERSTANDING THE C# OBJECT MODEL......Page 257
Chapter 7 Creating and managing classes and objects......Page 258
The purpose of encapsulation......Page 259
Defining and using a class......Page 260
Controlling accessibility......Page 261
Working with constructors......Page 264
Overloading constructors......Page 265
Deconstructing an object......Page 276
Understanding static methods and data......Page 278
Creating a shared field......Page 279
Creating a static field by using the const keyword......Page 280
Understanding static classes......Page 281
Static using statements......Page 282
Anonymous classes......Page 285
Quick reference......Page 287
Copying value type variables and classes......Page 290
Understanding null values and nullable types......Page 298
The null-conditional operator......Page 300
Using nullable types......Page 301
Understanding the properties of nullable types......Page 302
Using ref and out parameters......Page 303
Creating ref parameters......Page 304
Creating out parameters......Page 305
How computer memory is organized......Page 308
Using the stack and the heap......Page 310
The System.Object class......Page 311
Boxing......Page 312
Unboxing......Page 313
The is operator......Page 315
The as operator......Page 316
The switch statement revisited......Page 317
Quick reference......Page 321
Working with enumerations......Page 324
Using an enumeration......Page 325
Choosing enumeration literal values......Page 327
Choosing an enumeration’s underlying type......Page 328
Working with structures......Page 331
Declaring a structure......Page 333
Understanding differences between structures and classes......Page 334
Declaring structure variables......Page 336
Understanding structure initialization......Page 337
Copying structure variables......Page 342
Quick reference......Page 348
Declaring and creating an array......Page 350
Declaring array variables......Page 351
Creating an array instance......Page 352
Populating and using an array......Page 353
Creating an implicitly typed array......Page 354
Accessing an individual array element......Page 355
Iterating through an array......Page 356
Passing arrays as parameters and return values for a method......Page 358
Copying arrays......Page 361
Creating jagged arrays......Page 363
Accessing arrays that contain value types......Page 377
Quick reference......Page 381
Overloading—a recap......Page 384
Using array arguments......Page 386
Declaring a params array......Page 387
Using params object[ ]......Page 390
Using a params array......Page 392
Comparing parameter arrays and optional parameters......Page 395
Summary......Page 398
Quick reference......Page 399
What is inheritance?......Page 400
Using inheritance......Page 401
Calling base-class constructors......Page 404
Assigning classes......Page 406
Declaring new methods......Page 408
Declaring virtual methods......Page 410
Declaring override methods......Page 411
Understanding protected access......Page 414
Creating extension methods......Page 421
Summary......Page 426
Quick reference......Page 427
Chapter 13 Creating interfaces and defining abstract classes......Page 429
Understanding interfaces......Page 430
Defining an interface......Page 431
Implementing an interface......Page 432
Referencing a class through its interface......Page 434
Explicitly implementing an interface......Page 435
Defining and using interfaces......Page 438
Abstract classes......Page 450
Sealed classes......Page 452
Implementing and using an abstract class......Page 453
Summary......Page 461
Quick reference......Page 462
The life and times of an object......Page 464
Writing destructors......Page 466
Why use the garbage collector?......Page 469
How does the garbage collector work?......Page 471
Recommendations......Page 472
Disposal methods......Page 473
Exception-safe disposal......Page 474
The using statement and the IDisposable interface......Page 475
Calling the Dispose method from a destructor......Page 477
Implementing exception-safe disposal......Page 479
Summary......Page 490
Quick reference......Page 491
PART III DEFINING EXTENSIBLE TYPES WITH C#......Page 493
Chapter 15 Implementing properties to access fields......Page 494
Implementing encapsulation by using methods......Page 495
What are properties?......Page 497
Using properties......Page 500
Read-only properties......Page 501
Write-only properties......Page 502
Understanding the property restrictions......Page 503
Declaring interface properties......Page 506
Replacing methods with properties......Page 507
Generating automatic properties......Page 513
Initializing objects by using properties......Page 516
Quick reference......Page 521
What is an indexer?......Page 524
Storing binary values......Page 525
Displaying binary values......Page 526
Manipulating binary values......Page 527
Solving the same problems using indexers......Page 529
Understanding indexer accessors......Page 532
Comparing indexers and arrays......Page 533
Indexers in interfaces......Page 535
Using indexers in a Windows application......Page 536
Quick reference......Page 544
The problem: Misusing with the object type......Page 547
The generics solution......Page 551
Generics and constraints......Page 555
The theory of binary trees......Page 556
Building a binary tree class by using generics......Page 560
Creating a generic method......Page 572
Defining a generic method to build a binary tree......Page 573
Variance and generic interfaces......Page 576
Covariant interfaces......Page 578
Contravariant interfaces......Page 580
Summary......Page 583
Quick reference......Page 584
What are collection classes?......Page 586
The List collection class......Page 588
The LinkedList collection class......Page 591
The Queue collection class......Page 593
The Stack collection class......Page 595
The Dictionary collection class......Page 596
The SortedList collection class......Page 598
The HashSet collection class......Page 599
Using collection initializers......Page 601
The Find methods, predicates, and lambda expressions......Page 602
The forms of lambda expressions......Page 605
Comparing arrays and collections......Page 607
Using collection classes to play cards......Page 608
Quick reference......Page 613
Enumerating the elements in a collection......Page 616
Manually implementing an enumerator......Page 618
Implementing the IEnumerable interface......Page 624
A simple iterator......Page 627
Defining an enumerator for the Tree class by using an iterator......Page 630
Summary......Page 632
Quick reference......Page 633
Chapter 20 Decoupling application logic and handling events......Page 635
Understanding delegates......Page 636
Examples of delegates in the .NET Framework class library......Page 638
The automated factory scenario......Page 640
Implementing the factory by using a delegate......Page 641
Declaring and using delegates......Page 645
Creating a method adapter......Page 656
Declaring an event......Page 658
Subscribing to an event......Page 659
Raising an event......Page 660
Understanding user interface events......Page 661
Using events......Page 663
Summary......Page 670
Quick reference......Page 671
Chapter 21 Querying in-memory data by using query expressions......Page 674
Using LINQ in a C# application......Page 675
Selecting data......Page 678
Filtering data......Page 681
Ordering, grouping, and aggregating data......Page 682
Joining data......Page 685
Using query operators......Page 687
Querying data in Tree objects......Page 690
LINQ and deferred evaluation......Page 698
Summary......Page 702
Quick reference......Page 703
Understanding operators......Page 706
Operator constraints......Page 707
Overloaded operators......Page 708
Creating symmetric operators......Page 710
Understanding compound assignment evaluation......Page 712
Declaring increment and decrement operators......Page 713
Comparing operators in structures and classes......Page 714
Defining operator pairs......Page 715
Implementing operators......Page 716
Understanding conversion operators......Page 724
Providing built-in conversions......Page 725
Implementing user-defined conversion operators......Page 726
Creating symmetric operators, revisited......Page 727
Writing conversion operators......Page 728
Quick reference......Page 731
PART IV BUILDING UNIVERSAL WINDOWS PLATFORM APPLICATIONS WITH C#......Page 733
Why perform multitasking by using parallel processing?......Page 734
The rise of the multicore processor......Page 735
Implementing multitasking by using the Microsoft .NET Framework......Page 737
Tasks, threads, and the ThreadPool......Page 738
Creating, running, and controlling tasks......Page 740
Using the Task class to implement parallelism......Page 743
Abstracting tasks by using the Parallel class......Page 761
When not to use the Parallel class......Page 766
The mechanics of cooperative cancellation......Page 769
Summary......Page 786
Quick reference......Page 787
Chapter 24 Improving response time by performing asynchronous operations......Page 790
Defining asynchronous methods: The problem......Page 792
Defining asynchronous methods: The solution......Page 796
Defining asynchronous methods that return values......Page 805
Asynchronous method gotchas......Page 807
Asynchronous methods and the Windows Runtime APIs......Page 809
Tasks, memory allocation, and efficiency......Page 811
Using PLINQ to parallelize declarative data access......Page 815
Using PLINQ to improve performance while iterating through a collection......Page 816
Canceling a PLINQ query......Page 822
Synchronizing concurrent access to data......Page 823
Synchronization primitives for coordinating tasks......Page 827
The concurrent collection classes......Page 831
Using a concurrent collection and a lock to implement thread-safe data access......Page 832
Quick reference......Page 846
Chapter 25 Implementing the user interface for a Universal Windows Platform app......Page 850
Features of a Universal Windows Platform app......Page 852
Using the Blank App template to build a Universal Windows Platform app......Page 856
Implementing a scalable user interface......Page 859
Applying styles to a UI......Page 898
Quick reference......Page 911
Chapter 26 Displaying and searching for data in a Universal Windows Platform app......Page 913
Implementing the Model–View–ViewModel pattern......Page 914
Displaying data by using data binding......Page 915
Modifying data by using data binding......Page 923
Using data binding with a ComboBox control......Page 929
Creating a ViewModel......Page 932
Adding commands to a ViewModel......Page 937
Searching for data using Cortana......Page 950
Providing a vocal response to voice commands......Page 966
Quick reference......Page 970
Chapter 27 Accessing a remote database from a Universal Windows Platform app......Page 973
Retrieving data from a database......Page 974
Creating an entity model......Page 983
Creating and using a REST web service......Page 995
Inserting, updating, and deleting data through a REST web service......Page 1015
Reporting errors and updating the UI......Page 1028
Summary......Page 1038
Quick reference......Page 1039
Index......Page 1042
Code Snippets......Page 1247