Book description
Build your understanding and confidence with this hands-on guide to programming with C# 10 and .NET 6
Key Features
- Gain a solid foundation in C# and focus on coding real-world applications
- Learn how to write clean, effective code and think like a C# developer
- Build your experience and confidence with hands-on exercises and activities
Book Description
C# is a powerful, versatile language that can unlock a variety of career paths. But, as with any programming language, learning C# can be a challenging process. With a wide range of different resources available, it's difficult to know where to start.
That's where The C# Workshop comes in. Written and reviewed by industry experts, it provides a fast-paced, supportive learning experience that will quickly get you writing C# code and building applications. Unlike other software development books that focus on dry, technical explanations of the underlying theory, this Workshop cuts through the noise and uses engaging examples to help you understand how each concept is applied in the real world.
As you work through the book, you'll tackle realistic exercises that simulate the type of problems that software developers work on every day. These mini-projects include building a random-number guessing game, using the publisher-subscriber model to design a web file downloader, creating a to-do list using Razor Pages, generating images from the Fibonacci sequence using async/await tasks, and developing a temperature unit conversion app which you will then deploy to a production server.
By the end of this book, you'll have the knowledge, skills, and confidence to advance your career and tackle your own ambitious projects with C#.
What you will learn
- Understand the fundamentals of programming with C# 10 and .NET 6
- Build your familiarity with .NET CLI and Visual Studio Code
- Master the fundamentals of object-oriented programming (OOP)
- Understand and implement concurrency to write more efficient code
- Create a database and handle data using C#, SQL, and Entity Framework
- Build web applications using the ASP.NET framework
- Run automated unit tests with NUnit to validate your code
- Use principles including SOLID, KISS, ACID, DRY, and design patterns
Who this book is for
This book is for aspiring C# developers. It is recommended that you already have a basic understanding of core programming concepts before you start. Prior experience of another programming language would be beneficial, though it is not absolutely necessary.
Table of contents
- The C# Workshop
- Preface
-
1. Hello C#
- Introduction
- Running and Developing C# with the .NET CLI
- Data Types
- Classes
- Dates
-
Logical Operators and Boolean Expressions
- Using if-else Statements
- Exercise 1.06: Branching with if-else
- The Ternary Operator
- Reference and Value Types
- Exercise 1.07: Grasping Value and Reference Equality
- Enhancing Decision Making with the switch Statement
- Exercise 1.08: Using switch to Order Food
- Iteration Statements
- Exercise 1.09: Checking Whether a Number is Prime with a while Loop
- Exercise 1.10: Ordering an Array Using Bubble Sort
- File Handling
- Exercise 1.11: Reading Content from Text Files
- Exercise 1.12: Writing to a Text File
- Exceptions
- Exercise 1.13: Handling Invalid User Inputs with try/catch
- Activity 1.01: Creating a Guessing Game
- Summary
- 2. Building Quality Object-Oriented Code
-
3. Delegates, Events, and Lambdas
- Introduction
-
Delegates
- Defining a Custom Delegate
- Exercise 3.01: Defining and Invoking Custom Delegates
- The Inbuilt Action and Func Delegates
- Assigning Delegates
- Invoking a Delegate
- Exercise 3.02: Assigning and Invoking Delegates
- Multicast Delegates
- Exercise 3.03: Invoking a Multicast Delegate
- Exercise 3.04: Ensuring All Target Methods Are Invoked in a Multicast Delegate
- Events
- Defining an Event
- Exercise 3.05: Publishing and Subscribing to Events
- Events or Delegates?
- Lambda Expressions
- Summary
-
4. Data Structures and LINQ
- Introduction
- Data Structures
-
LINQ
- Query Operators
- Query Expressions
- Deferred Execution
- Standard Query Operators
- Filtering Operations
- Sorting Operations
- Exercise 4.03: Filtering a List of Countries by Continent and Sorting by Area
- Partitioning Operations
- Grouping Operations
- Exercise 4.04: Finding the Most Commonly Used Words in a Book
- Aggregation Operations
- Quantifier Operations
- Join Operations
- Using a let Clause in Query Expressions
- Activity 4.01: Treasury Flight Data Analysis
- Summary
-
5. Concurrency: Multithreading Parallel and Async Code
- Introduction
- Running Asynchronous Code Using Tasks
- Asynchronous Programming
- Summary
-
6. Entity Framework with SQL Server
- Introduction
- Creating a Demo Database Before You Start
- Querying a Database—LINQ to SQL
- Pitfalls of EF
- Working with a Database in Enterprise
- Summary
-
7. Creating Modern Web Applications with ASP.NET
- Introduction
-
Anatomy of an ASP.NET Web App
- Program.cs and the WebApplication
- Middlewares
- Logging
- Dependency Injection
- Exercise 7.01: Creating Custom Logging Middleware
- Dependency Lifetimes
- Razor Pages
- Exercise 7.02: Creating a Kanban Board with Razor
- PageModel
- Exercise 7.03: Creating Reusable Components with Tag Helpers
- Model Binding
- Exercise 7.04: Creating a New Page to Submit Tasks
- Validation
- Dynamic Behavior with Partial Pages
- Exercise 7.05: Refactoring a Tag Helper to a Partial Page with Custom Logic
- Activity 7.01: Creating a Page to Edit an Existing Task
- View Components
- Summary
-
8. Creating and Using Web API Clients
- Introduction
- Browser
- Web API
- Your Own Client
- RestSharp
- Refit
- Other Ways of Making HTTP Requests
- Summary
-
9. Creating API Services
- Introduction
-
ASP.NET Core Web API
- Creating a New Project
- Exercise 9.01: .NET Core Current Time Service
- Bootstrapping a Web API
- The Inner Workings of the AddLogging Method
- DI Examples within a Service
- Singleton
- Scoped
- Transient
- Exercise 9.02: Displaying Current Time in a Country API Time Zone
- OpenAPI and Swagger
- Error Handling
- Request Validation
- Configuration
- Bootstrapping
- Calling Another API
- Exercise 9.03: Performing File Operations by Calling Azure Blob Storage
- Securing a Web API
- Application Registration
- Implementing Web API Security
- Service-Oriented Architecture
- Activity 9.01: Implementing the File Upload Service Using Microservice Architecture
- Azure Functions
- Summary
Product information
- Title: The C# Workshop
- Author(s):
- Release date: September 2022
- Publisher(s): Packt Publishing
- ISBN: 9781800566491
You might also like
audiobook
The Design of Everyday Things
First, businesses discovered quality as a key competitive edge; next came science. Now, Donald A. Norman, …
book
C# in Depth, Fourth Edition
C# in Depth, Fourth Edition is your key to unlocking the powerful new features added to …
book
The HTML and CSS Workshop
Cut through the noise and get real results with a step-by-step approach to learning HTML and …
book
Head First C#, 5th Edition
What will you learn from this book? Create apps, games, and more using this engaging, highly …