Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Save more on your purchases! discount-offer-chevron-icon
Savings automatically calculated. No voucher code required.
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletter Hub
Free Learning
Arrow right icon
timer SALE ENDS IN
0 Days
:
00 Hours
:
00 Minutes
:
00 Seconds
The C# Workshop
The C# Workshop

The C# Workshop: Kickstart your career as a software developer with C#

Arrow left icon
Profile Icon Jason Hales Profile Icon Almantas Karpavicius Profile Icon Mateus Viegas
Arrow right icon
€38.99
Full star icon Full star icon Full star icon Full star icon Half star icon 4.5 (14 Ratings)
Paperback Sep 2022 780 pages 1st Edition
eBook
€27.99 €31.99
Paperback
€38.99
Subscription
Free Trial
Renews at €18.99p/m
Arrow left icon
Profile Icon Jason Hales Profile Icon Almantas Karpavicius Profile Icon Mateus Viegas
Arrow right icon
€38.99
Full star icon Full star icon Full star icon Full star icon Half star icon 4.5 (14 Ratings)
Paperback Sep 2022 780 pages 1st Edition
eBook
€27.99 €31.99
Paperback
€38.99
Subscription
Free Trial
Renews at €18.99p/m
eBook
€27.99 €31.99
Paperback
€38.99
Subscription
Free Trial
Renews at €18.99p/m

What do you get with Print?

Product feature icon Instant access to your digital copy whilst your Print order is Shipped
Product feature icon Paperback book shipped to your preferred address
Product feature icon Redeem a companion digital copy on all Print orders
Product feature icon Access this title in our online reader with advanced features
Product feature icon DRM FREE - Read whenever, wherever and however you want
Product feature icon AI Assistant (beta) to help accelerate your learning
OR
Modal Close icon
Payment Processing...
tick Completed

Shipping Address

Billing Address

Shipping Methods
Table of content icon View table of contents Preview book icon Preview Book

The C# Workshop

2. Building Quality Object-Oriented Code

Overview

In this chapter, you will learn how to simplify complex logic using Object-Oriented Programming (OOP). You will start by creating classes and objects, before exploring the four pillars of OOP. You will then learn about some of the best practices in coding, known as the SOLID principles, and see how you can use C# 10 features to write effective code guided by these principles. By the end of this chapter, you will be able to write clean code using object-oriented design with C#.

Introduction

How do people write software that is still maintainable even after many decades? What is the best way to model software around real-world concepts? The answer to both questions is Object Oriented Programming (OOP). OOP is a widely used paradigm in professional programming and is especially useful in enterprise settings.

OOP can be thought of as a bridge that connects real-world concepts and source code. A cat, for example, has certain defining properties, such as age, fur color, eye color, and name. The weather can be described using factors such as temperature and humidity. Both of these are real-world concepts that humans have identified and defined over time. In OOP, classes are what help in defining the logic of a program. When assigning concrete values to the properties of these classes, the result is an object. For example, using OOP, you can define a class for representing a room in a house, and then assign values to its properties (color and area) to create an object of that class.

In Chapter 1, Hello C#, you learned how to use C# to write basic programs. In this chapter, you will see how you can design your code by implementing OOP concepts and using C# at its best.

Classes and Objects

A class is like a blueprint that describes a concept. An object, on the other hand, is the result you get after the application of this blueprint. For example, weather can be a class, and 25 degrees and cloudless could refer to an object of this class. Similarly, you can have a class named Dog, while a four-year-old Spaniel can represent an object of the Dog class.

Declaring a class in C# is simple. It starts with the class keyword, followed by the class name and a pair of curly braces. To define a class named Dog, you can write the following code:

class Dog
{
}

Right now, this class is just an empty skeleton. However, it can still be used to create objects by using the new keyword, as follows:

Dog dog = new Dog();

This creates an object named dog. Currently, the object is an empty shell, as it lacks properties. You will see in an upcoming section how to define properties for classes, but first, you will explore constructors.

Left arrow icon Right arrow icon
Download code icon Download Code

Key benefits

  • 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

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#.

Who is this book 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.

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
Estimated delivery fee Deliver to Netherlands

Premium delivery 7 - 10 business days

€17.95
(Includes tracking information)

Product Details

Country selected
Publication date, Length, Edition, Language, ISBN-13
Publication date : Sep 27, 2022
Length: 780 pages
Edition : 1st
Language : English
ISBN-13 : 9781800566491
Category :
Languages :
Tools :

What do you get with Print?

Product feature icon Instant access to your digital copy whilst your Print order is Shipped
Product feature icon Paperback book shipped to your preferred address
Product feature icon Redeem a companion digital copy on all Print orders
Product feature icon Access this title in our online reader with advanced features
Product feature icon DRM FREE - Read whenever, wherever and however you want
Product feature icon AI Assistant (beta) to help accelerate your learning
OR
Modal Close icon
Payment Processing...
tick Completed

Shipping Address

Billing Address

Shipping Methods
Estimated delivery fee Deliver to Netherlands

Premium delivery 7 - 10 business days

€17.95
(Includes tracking information)

Product Details

Publication date : Sep 27, 2022
Length: 780 pages
Edition : 1st
Language : English
ISBN-13 : 9781800566491
Category :
Languages :
Tools :

Packt Subscriptions

See our plans and pricing
Modal Close icon
€18.99 billed monthly
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Simple pricing, no contract
€189.99 billed annually
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Choose a DRM-free eBook or Video every month to keep
Feature tick icon PLUS own as many other DRM-free eBooks or Videos as you like for just €5 each
Feature tick icon Exclusive print discounts
€264.99 billed in 18 months
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Choose a DRM-free eBook or Video every month to keep
Feature tick icon PLUS own as many other DRM-free eBooks or Videos as you like for just €5 each
Feature tick icon Exclusive print discounts

Frequently bought together


Stars icon
Total 114.97
The C# Workshop
€38.99
C# 11 and .NET 7 – Modern Cross-Platform Development Fundamentals
€37.99
Apps and Services with .NET 7
€37.99
Total 114.97 Stars icon

Table of Contents

9 Chapters
1. Hello C# Chevron down icon Chevron up icon
2. Building Quality Object-Oriented Code Chevron down icon Chevron up icon
3. Delegates, Events, and Lambdas Chevron down icon Chevron up icon
4. Data Structures and LINQ Chevron down icon Chevron up icon
5. Concurrency: Multithreading Parallel and Async Code Chevron down icon Chevron up icon
6. Entity Framework with SQL Server Chevron down icon Chevron up icon
7. Creating Modern Web Applications with ASP.NET Chevron down icon Chevron up icon
8. Creating and Using Web API Clients Chevron down icon Chevron up icon
9. Creating API Services Chevron down icon Chevron up icon

Customer reviews

Top Reviews
Rating distribution
Full star icon Full star icon Full star icon Full star icon Half star icon 4.5
(14 Ratings)
5 star 78.6%
4 star 7.1%
3 star 7.1%
2 star 0%
1 star 7.1%
Filter icon Filter
Top Reviews

Filter reviews by




Anthony Grippi Oct 26, 2022
Full star icon Full star icon Full star icon Full star icon Full star icon 5
First of all, I never write reviews. A product has to be pretty outstanding for me to take my time to write something, and for me to take up your time.I am a full-time student studying Computer Scince. I also work full time as a CRM Engineer. I have read this book and I am happy to say that it is really well done, but most importantly, it was a huge help to me in terms of my understanding of C# code!It is simply written but that is what is so great about it. The author goes through everything that my professors at university go through but in simpler terms. The author covers the basics thoroughly, and in roughly the same order as we are learning at school, as he mirrors everything that all of our professors/instructors/lab assistants are saying so it’s been good to read the information again, only differently.We all know there are thousands of books out there and not all of them are helpful, and in fact, make things worse by confusing the reader. This book reads like normal speech whereas most books on programming are like reading Greek, or some strange alien language. I often think to myself, "as if learning to code isn't confusing enough, and now I am going to read this textbook the size of New York and then be even more confused..." - well this book is not like that at all. It is thoughtfully written and the author has done a wonderful job of writing as if it is a conversation between two friends. So far, it’s been extremely helpful in sorting out some of my coding confusion, and I am always happy to share effective tools with others
Amazon Verified review Amazon
Peter Bull Oct 30, 2022
Full star icon Full star icon Full star icon Full star icon Full star icon 5
The C# Workshop is a great introduction to C# along with covering more intermediate and advanced topics. It gives you everything you need to get you started quickly with clear instructions on how to get everything set up and the exercises are easy to follow and can get instant results. Concepts are introduced at a good pace with well thought out examples with great attention to detail including pointing out expected differences in output depending on the reader’s location or language as well as considering the differences when creating new projects.The C# Workshop also helps break down the concepts of building object-oriented code with clear explanations about each concept with snippets that help explain them well with each exercise making it easier to understand as you progress through the concepts. More advanced concepts are handled well with explanations building on previous concepts to help advance through the topics being discussed from long held features to the latest functionality in C#.The C# Workshop will take you through beginner, intermediate and advanced topics but with a good foundation at each step it never seems like there’s too big a leap and exercises, examples and explanations at each stage help make sure you don’t get lost or confused along the way and help understand fundamental concepts along with creating modern applications, using a variety of features from PostgreSQL and Entity Framework to Web Applications with Razor and ASP.NET and get something working that you can learn from each step of the way.The C# Workshop is a great way to not only get your first taste of C# but to help advance learning the language with more intermediate and advanced topics, with exercises and examples to help understand throughout the book that even existing C# developers will find useful to add to their existing knowledge or just help make more sense of the functionality and features they use. I’d certainly recommend this book to anyone who wants to kickstart learning or to add to any knowledge for C#!
Amazon Verified review Amazon
Halbot Oct 31, 2022
Full star icon Full star icon Full star icon Full star icon Full star icon 5
Starting from the basics, but also importantly covers how to write quality code using OOO principles. Real world examples are useful and make it more approachable. It would have been nice to include Blazor as well as razor, but it covers the core aspects of C# well and in a clear manner.Overall a great resource and I would recommend to anyone starting out in C# programming.
Amazon Verified review Amazon
Craig Feb 17, 2023
Full star icon Full star icon Full star icon Full star icon Full star icon 5
Picked this book up to start my learning journey with C# and was very happy with it! This is the book you want if you're new to C#! I think the first chapters do a very good job in ramping someone new to C# up by slowly going over small and simple to understand examples. This is a trend that is followed in the book up to the very end even with some of the more advanced concepts -- Start with a small example of a concept and slowly build on it by adding more in-depth, more difficult concepts.Even being experienced with something like OOP I found nuggets of information useful in that chapter that made me wanna read the entire chapter without skipping any parts. I found the entire book so engaging I was never bored enough to be tempted to skip any parts. Each chapter does an amazing job of keeping the reader engaged.Data structures and LINQ are thoroughly explained in depth in an easy to understand way. The best explanation of LINQ is found within this book. Provided with powerful LINQ examples that will make your life writing C# much easier! More small simple to understand examples that are slowly built on makes learning and putting these idea into practice for someone new or experienced is a walk in the park.Often I find myself needing to re-reading chapters from tech books to better understand the topic at hand using my first pass on the chapter as a base foundation to build my understanding on. I don't think I did this once in the entire book! It is that well explained while being engaging if you're doing the coding sections in parallel with the book while you read! You feel your understand growing with each page turn and before you know it you're off and running with the more advanced topics like Entity Framework, Creating a web app using ASP.NET or creating your own Web API.If you're looking to start building with C# quickly while having a great understanding of your code I would highly recommend this read! Packt really hit the mark on this book! My hats off to the authors as well! Thank you, Jason Hales, Almantas Karpavicius, and Mateus Viegas! Fantastic read!
Amazon Verified review Amazon
Richard B Apr 08, 2023
Full star icon Full star icon Full star icon Full star icon Full star icon 5
These authors were meticulous and caring enough to include and speak to assumptions that other books and online courses seem to ignore. I recommend it as a first choice beginners and as a "a-ha" supplement for intermediates.
Amazon Verified review Amazon
Get free access to Packt library with over 7500+ books and video courses for 7 days!
Start Free Trial

FAQs

What is the digital copy I get with my Print order? Chevron down icon Chevron up icon

When you buy any Print edition of our Books, you can redeem (for free) the eBook edition of the Print Book you’ve purchased. This gives you instant access to your book when you make an order via PDF, EPUB or our online Reader experience.

What is the delivery time and cost of print book? Chevron down icon Chevron up icon

Shipping Details

USA:

'

Economy: Delivery to most addresses in the US within 10-15 business days

Premium: Trackable Delivery to most addresses in the US within 3-8 business days

UK:

Economy: Delivery to most addresses in the U.K. within 7-9 business days.
Shipments are not trackable

Premium: Trackable delivery to most addresses in the U.K. within 3-4 business days!
Add one extra business day for deliveries to Northern Ireland and Scottish Highlands and islands

EU:

Premium: Trackable delivery to most EU destinations within 4-9 business days.

Australia:

Economy: Can deliver to P. O. Boxes and private residences.
Trackable service with delivery to addresses in Australia only.
Delivery time ranges from 7-9 business days for VIC and 8-10 business days for Interstate metro
Delivery time is up to 15 business days for remote areas of WA, NT & QLD.

Premium: Delivery to addresses in Australia only
Trackable delivery to most P. O. Boxes and private residences in Australia within 4-5 days based on the distance to a destination following dispatch.

India:

Premium: Delivery to most Indian addresses within 5-6 business days

Rest of the World:

Premium: Countries in the American continent: Trackable delivery to most countries within 4-7 business days

Asia:

Premium: Delivery to most Asian addresses within 5-9 business days

Disclaimer:
All orders received before 5 PM U.K time would start printing from the next business day. So the estimated delivery times start from the next day as well. Orders received after 5 PM U.K time (in our internal systems) on a business day or anytime on the weekend will begin printing the second to next business day. For example, an order placed at 11 AM today will begin printing tomorrow, whereas an order placed at 9 PM tonight will begin printing the day after tomorrow.


Unfortunately, due to several restrictions, we are unable to ship to the following countries:

  1. Afghanistan
  2. American Samoa
  3. Belarus
  4. Brunei Darussalam
  5. Central African Republic
  6. The Democratic Republic of Congo
  7. Eritrea
  8. Guinea-bissau
  9. Iran
  10. Lebanon
  11. Libiya Arab Jamahriya
  12. Somalia
  13. Sudan
  14. Russian Federation
  15. Syrian Arab Republic
  16. Ukraine
  17. Venezuela
What is custom duty/charge? Chevron down icon Chevron up icon

Customs duty are charges levied on goods when they cross international borders. It is a tax that is imposed on imported goods. These duties are charged by special authorities and bodies created by local governments and are meant to protect local industries, economies, and businesses.

Do I have to pay customs charges for the print book order? Chevron down icon Chevron up icon

The orders shipped to the countries that are listed under EU27 will not bear custom charges. They are paid by Packt as part of the order.

List of EU27 countries: www.gov.uk/eu-eea:

A custom duty or localized taxes may be applicable on the shipment and would be charged by the recipient country outside of the EU27 which should be paid by the customer and these duties are not included in the shipping charges been charged on the order.

How do I know my custom duty charges? Chevron down icon Chevron up icon

The amount of duty payable varies greatly depending on the imported goods, the country of origin and several other factors like the total invoice amount or dimensions like weight, and other such criteria applicable in your country.

For example:

  • If you live in Mexico, and the declared value of your ordered items is over $ 50, for you to receive a package, you will have to pay additional import tax of 19% which will be $ 9.50 to the courier service.
  • Whereas if you live in Turkey, and the declared value of your ordered items is over € 22, for you to receive a package, you will have to pay additional import tax of 18% which will be € 3.96 to the courier service.
How can I cancel my order? Chevron down icon Chevron up icon

Cancellation Policy for Published Printed Books:

You can cancel any order within 1 hour of placing the order. Simply contact customercare@packt.com with your order details or payment transaction id. If your order has already started the shipment process, we will do our best to stop it. However, if it is already on the way to you then when you receive it, you can contact us at customercare@packt.com using the returns and refund process.

Please understand that Packt Publishing cannot provide refunds or cancel any order except for the cases described in our Return Policy (i.e. Packt Publishing agrees to replace your printed book because it arrives damaged or material defect in book), Packt Publishing will not accept returns.

What is your returns and refunds policy? Chevron down icon Chevron up icon

Return Policy:

We want you to be happy with your purchase from Packtpub.com. We will not hassle you with returning print books to us. If the print book you receive from us is incorrect, damaged, doesn't work or is unacceptably late, please contact Customer Relations Team on customercare@packt.com with the order number and issue details as explained below:

  1. If you ordered (eBook, Video or Print Book) incorrectly or accidentally, please contact Customer Relations Team on customercare@packt.com within one hour of placing the order and we will replace/refund you the item cost.
  2. Sadly, if your eBook or Video file is faulty or a fault occurs during the eBook or Video being made available to you, i.e. during download then you should contact Customer Relations Team within 14 days of purchase on customercare@packt.com who will be able to resolve this issue for you.
  3. You will have a choice of replacement or refund of the problem items.(damaged, defective or incorrect)
  4. Once Customer Care Team confirms that you will be refunded, you should receive the refund within 10 to 12 working days.
  5. If you are only requesting a refund of one book from a multiple order, then we will refund you the appropriate single item.
  6. Where the items were shipped under a free shipping offer, there will be no shipping costs to refund.

On the off chance your printed book arrives damaged, with book material defect, contact our Customer Relation Team on customercare@packt.com within 14 days of receipt of the book with appropriate evidence of damage and we will work with you to secure a replacement copy, if necessary. Please note that each printed book you order from us is individually made by Packt's professional book-printing partner which is on a print-on-demand basis.

What tax is charged? Chevron down icon Chevron up icon

Currently, no tax is charged on the purchase of any print book (subject to change based on the laws and regulations). A localized VAT fee is charged only to our European and UK customers on eBooks, Video and subscriptions that they buy. GST is charged to Indian customers for eBooks and video purchases.

What payment methods can I use? Chevron down icon Chevron up icon

You can pay with the following card types:

  1. Visa Debit
  2. Visa Credit
  3. MasterCard
  4. PayPal
What is the delivery time and cost of print books? Chevron down icon Chevron up icon

Shipping Details

USA:

'

Economy: Delivery to most addresses in the US within 10-15 business days

Premium: Trackable Delivery to most addresses in the US within 3-8 business days

UK:

Economy: Delivery to most addresses in the U.K. within 7-9 business days.
Shipments are not trackable

Premium: Trackable delivery to most addresses in the U.K. within 3-4 business days!
Add one extra business day for deliveries to Northern Ireland and Scottish Highlands and islands

EU:

Premium: Trackable delivery to most EU destinations within 4-9 business days.

Australia:

Economy: Can deliver to P. O. Boxes and private residences.
Trackable service with delivery to addresses in Australia only.
Delivery time ranges from 7-9 business days for VIC and 8-10 business days for Interstate metro
Delivery time is up to 15 business days for remote areas of WA, NT & QLD.

Premium: Delivery to addresses in Australia only
Trackable delivery to most P. O. Boxes and private residences in Australia within 4-5 days based on the distance to a destination following dispatch.

India:

Premium: Delivery to most Indian addresses within 5-6 business days

Rest of the World:

Premium: Countries in the American continent: Trackable delivery to most countries within 4-7 business days

Asia:

Premium: Delivery to most Asian addresses within 5-9 business days

Disclaimer:
All orders received before 5 PM U.K time would start printing from the next business day. So the estimated delivery times start from the next day as well. Orders received after 5 PM U.K time (in our internal systems) on a business day or anytime on the weekend will begin printing the second to next business day. For example, an order placed at 11 AM today will begin printing tomorrow, whereas an order placed at 9 PM tonight will begin printing the day after tomorrow.


Unfortunately, due to several restrictions, we are unable to ship to the following countries:

  1. Afghanistan
  2. American Samoa
  3. Belarus
  4. Brunei Darussalam
  5. Central African Republic
  6. The Democratic Republic of Congo
  7. Eritrea
  8. Guinea-bissau
  9. Iran
  10. Lebanon
  11. Libiya Arab Jamahriya
  12. Somalia
  13. Sudan
  14. Russian Federation
  15. Syrian Arab Republic
  16. Ukraine
  17. Venezuela