C# 10.0 All-in-One For Dummies
Häftad, Engelska, 2022
599 kr
Beställningsvara. Skickas inom 7-10 vardagar
Fri frakt för medlemmar vid köp för minst 249 kr.Look sharp—learn or refresh your C# skills with the latest version C# is one of the most popular programming languages, and frequent updates help it keep pace as the world of coding changes. You can keep pace too, thanks to C# 10.0 All-in-One For Dummies, where you'll learn the basics of the language itself, how to code in Visual Studio, and how to take advantage of the new features in the latest release. At every stage of your career, you'll need to know the cutting-edge trends and techniques that clients want. This book has your back, with info on object-oriented programming, writing secure code, building web applications, and more. The six standalone mini-books you'll find inside this all-in-one will take you through the changes to C# and the practical applications and dev tools that you need to know. New features covered include records, init only setters, top-level statements, pattern matching enhancements, fit and finish features, and a lot more. Plus, this version is packed with more examples and code snippets, so you can sharply see C# in action! Learn the very basics of C# programming, even if you have no prior experienceRefresh your knowledge of the language and learn how to use the new features in the 10.0 version releaseRead six mini-books on hot coding topics like object-oriented programming, Visual Studio, and Windows 10 developmentEnhance your employability and join the 6.5-million-strong community of C# developersYou need an easy-to-read C# guide that will help you understand the incoming updates, and this For Dummies reference is it.
Produktinformation
- Utgivningsdatum2022-02-17
- Mått188 x 234 x 51 mm
- Vikt1 134 g
- FormatHäftad
- SpråkEngelska
- Antal sidor864
- FörlagJohn Wiley & Sons Inc
- ISBN9781119839071
Tillhör följande kategorier
John Paul Mueller is an author and technical editor with experience in application development, database management, machine learning, and deep learning. He has written hundreds of books and articles helping everyday people learn everything from networking to database management.
- Introduction 1About This Book 1Foolish Assumptions 2Icons Used in This Book 3Beyond the Book 3Where to Go from Here 4Book 1: The Basics of C# Programming 5Chapter 1: Creating Your First C# Console Application 7Getting a Handle on Computer Languages, C#, and NET 8What’s a program? 8What’s C#? 9What’s NET? 9What is Visual Studio 2022? 10Creating Your First Console Application 11Creating the source program 11Taking it out for a test drive 17Making Your Console App Do Something 17Reviewing Your Console Application 18The program framework 19Comments 19The meat of the program 19Replacing All that Ceremonial Code: Top-Level Statements 20Introducing the Toolbox Trick 21Saving code in the Toolbox 22Reusing code from the Toolbox 22Interacting with C# Online 23Working with Jupyter Notebook: The Short Version 23Chapter 2: Living with Variability — Declaring Value-Type Variables 25Declaring a Variable 26What’s an int? 27Rules for declaring variables 28Variations on a theme: Different types of int 28Representing Fractions 30Handling Floating-Point Variables 31Declaring a floating-point variable 31Examining some limitations of floating-point variables 32Using the Decimal Type: Is It an Integer or a Float? 34Declaring a decimal 35Comparing decimals, integers, and floating-point types 35Examining the bool Type: Is It Logical? 36Checking Out Character Types 36The char variable type 36Special chars 37The string type 37What’s a Value Type? 39Comparing string and char 40Calculating Leap Years: DateTime 41Declaring Numeric Constants 43Changing Types: The Cast 44Letting the C# Compiler Infer Data Types 46Chapter 3: Pulling Strings 49The Union Is Indivisible, and So Are Strings 50Performing Common Operations on a String 51Comparing Strings 52Equality for all strings: The Compare() method 52Would you like your compares with or without case? 56What If I Want to Switch Case? 56Distinguishing between all-uppercase and all-lowercase strings 56Converting a string to upper- or lowercase 57Looping through a String 58Searching Strings 59Can I find it? 59Is my string empty? 60Using advanced pattern matching 60Getting Input from Users in Console Applications 61Trimming excess white space 62Parsing numeric input 62Handling a series of numbers 64Joining an array of strings into one string 66Controlling Output Manually 67Using the Trim() and Pad() methods 67Using the Concatenate() method 69Go Ahead and Split() that concatenate program 71Formatting Your Strings Precisely 72Using the String.Format() method 72Using the interpolation method 77StringBuilder: Manipulating Strings More Efficiently 77Chapter 4: Smooth Operators 81Performing Arithmetic 81Simple operators 82Operating orders 82The assignment operator 84The increment operator 84Performing Logical Comparisons — Is That Logical? 85Comparing floating-point numbers: Is your float bigger than mine? 86Compounding the confusion with compound logical operations 87Matching Expression Types at TrackDownAMate.com 89Calculating the type of an operation 89Assigning types 91Changing how an operator works: Operator overloading 92Chapter 5: Getting into the Program Flow 95Branching Out with if and switch 96Introducing the if statement 97Examining the else statement 100Avoiding even the else 101Nesting if statements 102Running the switchboard 104Here We Go Loop-the-Loop 110Looping for a while 111Doing the do while loop 114Breaking up is easy to do 115Looping until you get it right 116Focusing on scope rules 120Looping a Specified Number of Times with for 120A for loop example 121Why do you need another loop? 122Nesting loops 123Chapter 6: Lining Up Your Ducks with Collections 125The C# Array 126The argument for the array 126The fixed-value array 127The variable-length array 129Initializing an array 132Processing Arrays by Using foreach 133Working with foreach loops in a standard way 133Relying on GetEnumerator support 134Sorting Arrays of Data 136Using var for Arrays 139Loosening Up with C# Collections 140Understanding Collection Syntax 141Figuring out 142Going generic 142Using Lists 143Instantiating an empty list 143Creating a list of type int 144Converting between lists and arrays 144Searching lists 144Performing other list tasks 145Using Dictionaries 145Creating a dictionary 145Searching a dictionary 146Iterating a dictionary 146Array and Collection Initializers 147Initializing arrays 148Initializing collections 148Using Sets 149Performing special set tasks 149Creating a set 150Adding items to a set 150Performing a union 151Performing an intersection 152Performing a difference 153Chapter 7: Stepping through Collections 155Iterating through a Directory of Files 156Using the LoopThroughFiles program 156Getting started 157Obtaining the initial input 157Creating a list of files 159Formatting the output lines 160Displaying the hexadecimal output 161Running from inside Visual Studio 163Iterating foreach Collections: Iterators 164Accessing a collection: The general problem 164Letting C# access data foreach container 167Accessing Collections the Array Way: Indexers 169Indexer format 169An indexer program example 170Looping Around the Iterator Block 173Creating the required iterator block framework 174Iterating days of the month: A first example 176What a collection is, really 177Iterator syntax gives up so easily 178Iterator blocks of all shapes and sizes 180Chapter 8: Buying Generic 187Writing a New Prescription: Generics 188Generics are type-safe 188Generics are efficient 189Classy Generics: Writing Your Own 190Shipping packages at OOPs 190Queuing at OOPs: PriorityQueue 191Unwrapping the package 194Touring Main() 196Writing generic code the easy way 197Saving PriorityQueue for last 198Using a (nongeneric) Simple Factory class 201Understanding Variance in Generics 205Contravariance 206Covariance 208Chapter 9: Some Exceptional Exceptions 209Using an Exceptional Error-Reporting Mechanism 210About try blocks 211About catch blocks 211About finally blocks 212What happens when an exception is thrown 213Throwing Exceptions Yourself 215Can I Get an Exceptional Example? 216Working with Custom Exceptions 220Planning Your Exception-Handling Strategy 221Some questions to guide your planning 221Guidelines for code that handles errors well 222How to find out which methods throw which exceptions 223Grabbing Your Last Chance to Catch an Exception 225Throwing Expressions 226Chapter 10: Creating Lists of Items with Enumerations 229Seeing Enumerations in the Real World 230Working with Enumerations 231Using the enum keyword 231Creating enumerations with initializers 233Specifying an enumeration data type 234Creating Enumerated Flags 235Defining Enumerated Switches 237Working with Enumeration Methods 238Book 2: Object-Oriented C# Programming 241Chapter 1: Showing Some Class 243A Quick Overview of Object-Oriented Programming 244Considering OOP basics 244Extending classes to meet other needs 244Keeping objects safe 245Working with objects 246Defining a Class and an Object 246Defining a class 247What’s the object? 249Accessing the Members of an Object 250Working with Object-Based Code 250Using the traditional approach 250Using the C# 9.0 approach 252Discriminating between Objects 253Can You Give Me References? 254Classes That Contain Classes Are the Happiest Classes in the World 256Generating Static in Class Members 257Defining const and readonly Data Members 259Chapter 2: We Have Our Methods 261Defining and Using a Method 262Method Examples for Your Files 263Understanding the problem 264Working with standard coding methods 265Applying a refactoring approach 268Working with local functions 271Having Arguments with Methods 273Passing an argument to a method 273Passing multiple arguments to methods 274Matching argument definitions with usage 276Overloading a method doesn’t mean giving it too much to do 276Implementing default arguments 278Using the Call-by-Reference Feature 280Defining a Method with No Return Value 281Returning Multiple Values Using Tuples 282Using a tuple 283Relying on the Create() method 284Creating tuples with more than two items 284Chapter 3: Let Me Say This about this 287Passing an Object to a Method 288Comparing Static and Instance Methods 290Employing static properties and methods effectively 291Employing instance properties and methods effectively 293Expanding a method’s full name 295Accessing the Current Object 296What is the this keyword? 298When is the this keyword explicit? 299Using Local Functions 300Creating a basic local function 300Using attributes with local functions 301Chapter 4: Holding a Class Responsible 303Restricting Access to Class Members 303A public example of public BankAccount 304Jumping ahead — other levels of security 306Why You Should Worry about Access Control 307Accessor methods 308Working with init-only setters 309Access control to the rescue — an example 311Defining Class Properties 313Static properties 315Properties with side effects 315Accessors with access levels 316Using Target Typing for Your Convenience 316Dealing with Covariant Return Types 319Getting Your Objects Off to a Good Start — Constructors 320The C#-Provided Constructor 321Replacing the Default Constructor 322Constructing something 324Initializing an object directly with an initializer 326Seeing that construction stuff with initializers 326Initializing an object without a constructor 327Using Expression-Bodied Members 329Creating expression-bodied methods 329Defining expression-bodied properties 329Defining expression-bodied constructors and destructors 330Defining expression-bodied property accessors 330Defining expression-bodied event accessors 331Chapter 5: Inheritance: Is That All I Get? 333Why You Need Inheritance 334Inheriting from a BankAccount Class (a More Complex Example) 335Working with the basic update 336Tracking the BankAccount and SavingsAccount classes features 339IS_A versus HAS_A — I’m So Confused_A 342The IS_A relationship 342Gaining access to BankAccount by using containment 343The HAS_A relationship 345When to IS_A and When to HAS_A 346Other Features That Support Inheritance 346Substitutable classes 346Invalid casts at runtime 347Avoiding invalid conversions with the is operator 348Avoiding invalid conversions with the as operator 349Chapter 6: Poly-what-ism? 353Overloading an Inherited Method 354It’s a simple case of method overloading 354Different class, different method 355Peek-a-boo — hiding a base class method 355Polymorphism 361Using the declared type every time (Is that so wrong?) 362Using is to access a hidden method polymorphically 364Declaring a method virtual and overriding it 365Getting the most benefit from polymorphism 368C# During Its Abstract Period 368Class factoring 369The abstract class: Left with nothing but a concept 373How do you use an abstract class? 374Creating an abstract object — not! 377Sealing a Class 377Chapter 7: Interfacing with the Interface 379Introducing CAN_BE_USED_AS 379Knowing What an Interface Is 381How to implement an interface 382Using the newer C# 8.0 additions 383How to name your interface 386Why C# includes interfaces 386Mixing inheritance and interface implementation 387And he-e-e-re’s the payoff 387Using an Interface 388As a method return type 389As the base type of an array or collection 389As a more general type of object reference 390Using the C# Predefined Interface Types 390Looking at a Program That CAN_BE_USED_AS an Example 391Creating your own interface at home in your spare time 391Implementing the incomparable I Comparable interface 392Creating a list of students 394Testing everything using Main() 395Unifying Class Hierarchies 396Hiding Behind an Interface 399Inheriting an Interface 401Using Interfaces to Manage Change in Object-Oriented Programs 402Making flexible dependencies through interfaces 403Abstract or concrete: When to use an abstract class and when to use an interface 404Doing HAS_A with interfaces 405Chapter 8: Delegating Those Important Events 407E.T., Phone Home — The Callback Problem 408Defining a Delegate 408Pass Me the Code, Please — Examples 411Delegating the task 411First, a simple example 412Considering the Action, Func, and Predicate delegate types 413A More Real-World Example 415Putting the app together 416Setting the properties and adding event handlers 418Looking at the workhorse code 419Shh! Keep It Quiet — Anonymous Methods 421Defining the basic anonymous method 421Using static anonymous methods 422Working with lambda discard parameters 424Stuff Happens — C# Events 424The Observer design pattern 425What’s an event? Publish/Subscribe 425How a publisher advertises its events 426How subscribers subscribe to an event 427How to publish an event 427How to pass extra information to an event handler 428A recommended way to raise your events 429How observers “handle” an event 430Chapter 9: Can I Use Your Namespace in the Library? 433Dividing a Single Program into Multiple Source Files 434Working with Global using Statements 435Dividing a Single Program into Multiple Assemblies 437Executable or library? 437Assemblies 437Executables 438Class libraries 439Putting Your Classes into Class Libraries 439Creating the projects for a class library 439Creating a stand-alone class library 440Adding a second project to an existing solution 442Creating the code for the library 445Using a test application to test a library 446Going Beyond Public and Private: More Access Keywords 448Internal: For CIA eyes only 448Protected: Sharing with subclasses 451Putting Classes into Namespaces 453Declaring a namespace 454Using file-scoped namespaces 456Relating namespaces to the access keyword story 456Using fully qualified names 458Working with partial classes 459Working with Partial Methods 463Defining what partial methods do 463Creating a partial method 464Chapter 10: Improving Productivity with Named and Optional Parameters 465Exploring Optional Parameters 466Working with optional value parameters 466Avoiding optional reference types 468Looking at Named Parameters 470Using Alternative Methods to Return Values 470Output (out) parameters 471Working with out variables 471Returning values by reference 472Dealing with null Parameters 473Chapter 11: Interacting with Structures 475Comparing Structures to Classes 476Considering struct limits 476Understanding the value type difference 477Determining when to use struct versus class 477Creating Structures 478Defining a basic struct 478Including common struct elements 479Using supplemental struct elements 482Working with Read-only Structures 485Working with Reference Structures 487Using Structures as Records 489Managing a single record 489Adding structures to arrays 489Overriding methods 490Using the New Record Type 491Comparing records to structures and classes 491Working with a record 492Using the positional syntax for property definition 493Understanding value equality 494Creating safe changes: Nondestructive mutation 494Using the field keyword 495Book 3: Designing For C# 497Chapter 1: Writing Secure Code 499Designing Secure Software 500Determining what to protect 500Documenting the components of the program 501Decomposing components into functions 502Identifying potential threats in functions 502Building Secure Windows Applications 503Authentication using Windows logon 503Encrypting information 507Deployment security 507Using System.Security 508Chapter 2: Accessing Data 509Getting to Know System.Data 510How the Data Classes Fit into the Framework 512Getting to Your Data 512Using the System.Data Namespace 513Setting up a sample database schema 513Creating the data access project 514Connecting to a data source 514Working with the visual tools 519Writing data code 521Chapter 3: Fishing the File Stream 525Going Where the Fish Are: The File Stream 525Streams 526Readers and writers 527StreamWriting for Old Walter 528Using the stream: An example 529Using some better fishing gear: The using statement 534Pulling Them Out of the Stream: Using StreamReader 537More Readers and Writers 539Exploring More Streams than Lewis and Clark 541Chapter 4: Accessing the Internet 543Getting to Know System.Net 544How Net Classes Fit into the Framework 545Understanding the System.Net subordinate namespaces 545Working with the System.Net classes 548Using the System.Net Namespace 549Checking the network status 549Downloading a file from the Internet 551Emailing a status report 553Logging network activity 556Chapter 5: Creating Images 559Getting to Know System.Drawing 560Graphics 561Pens 562Brushes 563Text 563How the Drawing Classes Fit into the Framework 564Using the System.Drawing Namespace 565Getting started 565Setting up the project 567Handling the score 567Creating an event connection 569Drawing the board 570Printing the score 572Starting a new game 574Chapter 6: Programming Dynamically! 575Shifting C# Toward Dynamic Typing 576Employing Dynamic Programming Techniques 578Putting Dynamic to Use 580Classic examples 580Making static operations dynamic 581Understanding what’s happening under the covers 581Running with the Dynamic Language Runtime 582Using Static Anonymous Functions 585Book 4: A Tour of Visual Studio 587Chapter 1: Getting Started with Visual Studio 589Versioning the Versions 590An overview of Visual Studio 2022 updates 590Community edition 592Professional edition 594Enterprise edition 594MSDN 595Installing Visual Studio 596Breaking Down the Projects 597Exploring the Create a New Project dialog box 600Understanding solutions and projects 601Chapter 2: Using the Interface 603Designing in the Designer 604Universal Windows Platform (UWP) application 604Windows Presentation Foundation (WPF) 607Windows Forms 609Data View 609Paneling the Studio 610Solution Explorer 610Properties 613The Toolbox 614Server Explorer 615Class View 617Coding in the Code Editor 618Exercising the Code Editor 618Exploring the auxiliary windows 619Using the Tools of the Trade 621The Tools menu 622Building 623Using the Debugger as an Aid to Learning 623Stepping through code 623Going to a particular code location 624Watching application data 625Viewing application internals 626Chapter 3: Customizing Visual Studio 627Setting Options 628Environment 629Language 630Neat stuff 631Creating Your Own Templates 632Developing a project template 632Developing an item template 635Book 5: Windows Development with Wpf 639Chapter 1: Introducing WPF 641Understanding What WPF Can Do 642Introducing XAML 643Diving In! Creating Your First WPF Application 644Declaring an application-scoped resource 647Making the application do something 648Whatever XAML Can Do, C# Can Do Better! 650Chapter 2: Understanding the Basics of WPF 653Using WPF to Lay Out Your Application 654Arranging Elements with Layout Panels 655The Stack panel 656The Wrap panel 660The Dock panel 661Canvas 662The Grid 662Putting it all together with a simple data entry form 669Exploring Common XAML Controls 672Display-only controls 672Basic input controls 674List-based controls 677Chapter 3: Data Binding in WPF 681Getting to Know Dependency Properties 682Exploring the Binding Modes 683Investigating the Binding Object 683Defining a binding with XAML 684Defining a binding with C# 686Editing, Validating, Converting, and Visualizing Your Data 687Validating data 693Converting your data 697Finding Out More about WPF Data Binding 705Chapter 4: Practical WPF 707Commanding Attention 708Traditional event handling 708ICommand 709Routed commands 710Using Built-In Commands 711Using Custom Commands 713Defining the interface 713Creating the window binding 714Ensuring that the command can execute 714Performing the task 715Using Routed Commands 717Defining the Command class 717Making the namespace accessible 718Adding the command bindings 718Developing a user interface 718Developing the custom command code-behind 719Chapter 5: Programming for Windows 10 and Above 721What is the Universal Windows Platform (UWP)? 722Devices Supported by the UWP 725Creating Your Own UWP App 726Configuring Developer Mode 726Defining the project 732Creating an interface 734Adding some background code 738Choosing a test device 739Working with NET Core Applications 740Book 6: Web Development with Asp.Net 743Chapter 1: Creating a Basic ASP.NET Core App 745Understanding the ASP.NET Core Templates 746Starting with nothing using ASP.NET Core Empty 746Creating a basic app using the ASP.NET Core Web App 748Fumbling around with HTTPS-enabled sites 749Building in business logic using ASP.NET Core App (Model-View-Controller) 751Developing a programming interface using ASP.NETCore Web API 752An overview of those other weird templates 753Developing a Basic Web App 754Creating the project 754Considering the development process 756Adding web content 757Making some basic changes to the first page 759Chapter 2: Employing the Razor Markup Language 761Avoiding Nicks from Razor 762Comparing Razor to its predecessors 762Considering the actual file layout 763Understanding the syntax rules for C# 766Working with some Razor basics 767Creating Variables 770Keeping Things Logical 771Starting simply by using if 771Sleeping at the switch 771Implementing Loops 772Creating an array 772Performing tasks a specific number of times using for 773Processing an unknown number of times using for each and while 773Chapter 3: Generating and Consuming Data 775Understanding Why These Projects Are Important 776Serialized Data Isn’t for Breakfast 777Developing a Data Generator and API 778Creating the WeatherForecast project 778Making the data believable 781Looking at the API configuration 783Checking the API for functionality 784Creating a Consumer Website 786Creating the RetrieveWeatherForecast project 786Developing a user interface 787Getting and deserializing the data 789Seeing the application in action 793Index 795