+353-1-416-8900REST OF WORLD
+44-20-3973-8888REST OF WORLD
1-917-300-0470EAST COAST U.S
1-800-526-8630U.S. (TOLL FREE)

Beginning C# 7 Programming with Visual Studio 2017. Edition No. 1

  • Book

  • 912 Pages
  • May 2018
  • John Wiley and Sons Ltd
  • ID: 4402164

 Easily get started programming using the ultra-versatile C# 7 and Visual Studio 2017

Beginning C# 7 Programming with Visual Studio 2017 is the beginner’s ultimate guide to the world’s most popular programming language. Whether you’re new to programming entirely, or just new to C#, there has never been a better time to get started. The new C# 7 and Visual Studio 2017 updates feature a number of new tools and features that streamline the workflow, simplify the code, and make it easier than ever to build high-quality apps. This book walks you through everything you need to know, starting from the very basics, to have you programming in no time. You’ll learn about variables, flow control, and object oriented programming, then move into Web and Windows programming as well as databases and XML. The companion website provides downloadable code examples, and practical Try It Out sections provide explicit, step-by-step instructions for writing your own useful, customizable code.

C# 7 can be used to build Windows applications, program Windows 10, and write Web apps when used alongside ASP.NET. With programming skills becoming de rigueur in fields far beyond the tech world, C# 7 is a great place to start building versatile, helpful skills. This book gets you started quickly and easily with instruction from a master-team of C# programmers.

  • Learn how to program using the world’s leading programming language
  • Build smarter, faster apps using the latest features in C# 7 and Visual Studio 2017
  • Find and fix bugs sooner, saving headaches down the line
  • Integrate with all .NET Core, Azure applications, cloud services, Docker containers, and more

The world of programming can seem intimidating to a beginner, and the prospect of learning a whole new “language” can seem daunting. Beginning C# 7 Programming with Visual Studio 2017 demystifies the process and shows you how to bring your ideas to life.

Table of Contents

Introduction xxi

Part I: The C# Language

Chapter 1: Introducing C# 3

What Is the .NET Framework? 4

What Is C#? 9

Visual Studio 2017 11

Chapter 2: Writing a C# Program 15

The Visual Studio 2017 Development Environment 16

Console Applications 21

Desktop Applications 26

Chapter 3: Variables and Expressions 33

Basic C# Syntax 34

Basic C# Console Application Structure 36

Variables 38

Expressions 46

Chapter 4: Flow Control 59

Boolean Logic 60

Branching 65

Looping 72

Chapter 5: More About Variables 83

Type Conversion 84

Complex Variable Types 91

String Manipulation 109

Chapter 6: Functions 117

Defining and Using Functions 118

Variable Scope 131

The Main() Function 138

Struct Functions 141

Overloading Functions 142

Using Delegates 144

Chapter 7: Debugging and Error Handling 149

Debugging in Visual Studio 150

Error Handling 167

Chapter 8: Introduction To Object-Oriented Programming 179

What Is Object-Oriented Programming? 180

OOP Techniques 186

OOP in Desktop Applications 196

Chapter 9: Defining Classes 203

Class Definitions in C# 204

System. Object 209

Constructors and Destructors 211

OOP Tools in Visual Studio 216

Class Library Projects 222

Interfaces Versus Abstract Classes 226

Struct Types 228

Shallow Copying Versus Deep Copying 230

Chapter 10: Defining Class Members 233

Member Definitions 234

Additional Class Member Topics 244

Interface Implementation 249

Partial Class Definitions 252

Partial Method Definitions 253

Example Application 255

The Call Hierarchy Window 265

Chapter 11: Collections, Comparisons, and Conversions 269

Collections 270

Comparisons 292

Conversions 313

Chapter 12: Generics 319

What Are Generics? 320

Using Generics 321

Defining Generic Types 339

Variance 353

Chapter 13: Additional C# Techniques 359

The :: Operator and the Global Namespace Qualifier 360

Custom Exceptions 361

Events 363

Expanding and Using CardLib 375

Attributes 384

Initializers 386

Type Inference 392

Anonymous Types 394

Dynamic Lookup 398

Advanced Method Parameters 402

Lambda Expressions 409

Part II: Windows Programming

Chapter 14: Basic Desktop Programming 425

XAML 426

The Playground 429

Control Layout 441

The Game Client 452

Chapter 15: Advanced Desktop Programming 479

Creating and Styling Controls 480

WPF User Controls 485

The Main Window 499

Putting It All Together 504

Part III: Cloud and Cross-Platform Programming

Chapter 16: Basic Cloud Programming 533

The Cloud, Cloud Computing, and the Cloud Optimized Stack 534

Cloud Patterns and Best Practices 537

Using Microsoft Azure C# Libraries to Create a Storage Container 538

Creating an ASP.NET 4.7 Web Site That Uses the Storage Container 548

Chapter 17: Advanced Cloud Programming and Deployment 559

Creating an ASP.NET Web API 560

Deploying and Consuming an ASP.NET Web API on

Microsoft Azure 564

Scaling an ASP.NET Web API on Microsoft Azure 572

Chapter 18: .NET standard and .NET Core 579

Cross-Platform Basics and Key “Must Know” Terms 581

What Is .NET Standard, and Why Is It Needed? 583

Referencing and Targeting Frameworks 587

What is .NET Core? 588

Building and Packaging a .NET Standard Library 596

Building a .NET Core Application with Visual Studio 602

Porting from .NET Framework to .NET Core 605

Chapter 19: ASP.NET and ASP.NET Core 609

Overview of Web Applications 610

Which ASP.NET to Use and Why 611

Using ASP.NET Web Forms 620

Creating ASP.NET Core Web Applications 627

Part IV: Data Access

Chapter 20: Files 641

File Classes for Input and Output 642

Streams 647

Monitoring the File System 664

Chapter 21: XML and JSON 673

XML Basics 674

JSON Basics 674

XML Schemas 675

XML Document Object Model 677

Converting XML to JSON 689

Searching XML with XPath 691

Chapter 22: LINQ 697

LINQ to XML 698

LINQ Providers 704

LINQ Query Syntax 705

LINQ Method Syntax 709

Ordering Query Results 712

Understanding the orderby Clause 713

Querying a Large Data Set 714

Using Aggregate Operators 717

Using the Select Distinct Query 720

Ordering by Multiple Levels 723

Using Group Queries 725

Using Joins 727

Chapter 23: Databases 731

Using Databases 731

Installing SQL Server Express 732

Entity Framework 732

A Code First Database 733

But Where Is My Database? 740

Navigating Database Relationships 742

Handling Migrations 749

Creating and Querying XML from an Existing Database 750

Part V: Additional Techniques

Chapter 24: Windows Communication Foundation 761

What Is WCF? 762

WCF Concepts 763

WCF Programming 768

Chapter 25: Universal Apps 793

Getting Started 794

Windows Universal Apps 795

App Concepts and Design 796

App Development 797

Common Elements of Windows Store Apps 816

The Windows Store 818

Appendix: Exercise Solutions 821

Index 865

Authors

Benjamin Perkins Jacob Vibe Hammer Jon D. Reid