Leanpub Header

Skip to main content

Discover Programming with C#

Featuring .NET Core 3 & C# 8

Everyone should be able to learn to program. This book teaches beginners to program with the C# language. It builds a foundation on which to base a lifetime of programming. This book targets .NET Core 3 and C# 8.

Minimum price

$14.99

$14.99

You pay

$14.99

Author earns

$11.99
$

...Or Buy With Credits!

You can get credits monthly with a Reader Membership
PDF
EPUB
WEB
233
Pages
55,755Words
About

About

About the Book

This is a book for those who are interested in learning how to program. It introduces C#, a modern object-oriented, cross-platform language that is used extensively in business and web applications. It provides a robust library of functionality that increases cross-platform capabilities and prevents programmers from constantly having to implement basic and advanced functionality from networking to I/O operations to security functions. C# and .NET have a vibrant developer community and are commercially supported by Microsoft.

I have been programming C# since its public release in early 2002. I have used it for web development, system administration, and database applications. I have used it in the educational, financial, telecom, warehouse management, and procurement sectors. C# is not the first language I learned to program, but it has been my most productive.

This book does not start out with the reader copying text into a text editor. It begins with a thorough foundation of the basics of programming C#. Many programmers that I interview today do not know the foundational basics required to be great C# programmers. The typical pattern for learning C# in recent years has been to code first and ask questions later. These questions are rarely asked and often lead to poor quality software.

This book does make some generalizations and does not cover every aspect of the C# language such as bitwise operations. It provides the reader with the amount of information I feel is relevant to creating a good programmer. There are many great resources available for learning about the history of computing, design patterns, refactoring, object-oriented programming, Entity Framework, and ASP.NET MVC. This book prepares you to understand those books.

I hope this book is helpful to all those who read it. I taught myself to program and hope to help you do the same.

The Author

Share this book

Installments completed

3 / 12

License

Creative Commons Attribution-ShareAlike 4.0 International License

Author

About the Author

Jason L. Cable

Jason L. Cable is a full-stack .NET developer residing in Pittsburgh, PA. He has specialized in C# since its release in 2002. Jason has diverse experience in the Information Technology field. He started in 1996 at the age of 16 as a telephone technical support specialist with a local internet service provider. He has worked as UNIX/Linux systems administrator, Windows desktop support technician, Windows system administrator, webmaster specializing in Perl development, SQL Server DBA, development team lead and manager, and full-stack .NET web developer. Jason also has experience in DevOps, networking architecture, software architecture and best practices, and cloud computing.

Jason is a strong believer in open source software and the elimination of software patents. The internet pioneers were unencumbered by the limits of the patent system. Without their ability to publicly publish their ideas and collaborate with peers, Jason feels that we would not enjoy the benefits of an open internet that we have today.

Jason has a Bachelor of Arts degree in Psychology from Ashford University.

Contents

Table of Contents

Pre-release Notes

Introduction

A Word to the Reader

Code License

Some Definitions

1.Milestones

  1. 1.1Early Systems
  2. 1.2The Next Generation
  3. 1.3Higher Level Languages
  4. 1.4What’s in an Operating System?
  5. 1.5C Follows B and So Goes the World

2.First Things First

  1. 2.1Runtimes
  2. 2.2Frameworks
  3. 2.3.NET Standard
  4. 2.4.NET 5
  5. 2.5Starting Out
  6. 2.6Variables
  7. 2.7A Bit about Bits
  8. 2.8Scalars
  9. 2.9Math Operators

3.Strings

  1. 3.1Garbage Collection
  2. 3.2Sorting and Encoding Strings
  3. 3.3Creating a String
  4. 3.4@ Character
  5. 3.5Character Literals
  6. 3.6Nullable Types

4.Array Basics

  1. 4.1Definition
  2. 4.2Single-dimensional Arrays
  3. 4.3Multidimensional Arrays
  4. 4.4Jagged Arrays

5.Logic and Control Structures

  1. 5.1Boolean Logic or Black & White
  2. 5.2if Statements
  3. 5.3Short-circuit Operators
  4. 5.4Other Operators

6.More Logic and Control Structures

  1. 6.1Conditional Access Operators
  2. 6.2Null Coalescing Operator
  3. 6.3Basic Switch Statement Usage
  4. 6.4The Dreaded goto Statement
  5. 6.5Iteration and Loops
  6. 6.6break and continue
  7. 6.7for
  8. 6.8Variable Scoping: The Basics
  9. 6.9foreach
  10. 6.10The var Keyword

7.Objects and Classes, Part 1

  1. Author’s Note
  2. 7.1The Four Principles of OOP
  3. 7.2What’s in a namespace?
  4. 7.3Classes and Their Members
  5. 7.4Static vs. Instance Members
  6. 7.5Fields (Static and Instance)
  7. 7.6Methods (Static and Instance)
  8. 7.7Pass by Value vs. Pass by Reference
  9. 7.8The Difference Between Reference and Value Types
  10. 7.9Passing Reference Types By Reference
  11. 7.10Out Parameters
  12. 7.11The params Array
  13. 7.12Optional Parameters
  14. 7.13Named Parameters
  15. 7.14Chaining Methods
  16. 7.15Extension Methods
  17. 7.16Method Overloading
  18. 7.17Properties (Static and Instance)

8.Objects and Classes, Part 2

  1. 8.1Access Modifiers and Accessibility Types
  2. 8.2Constructors (Static and Instance)
  3. 8.3Static Constructors
  4. 8.4Expression-bodied Members

9.Exceptions

  1. 9.1A Brief Introduction to Inheritance
  2. 9.2Handling Exceptions
  3. 9.3An Example and Three Questions
  4. 9.4throw Your Own
  5. 9.5Another Example

10.Objects and Classes, Part 3

  1. 10.1Operators (Instance)
  2. 10.2Type Casting and Boxing/Unboxing
  3. 10.3Implementing Type Conversions
  4. 10.4Indexers (Instance)
  5. 10.5Events (Instance)
  6. 10.6Finalizers (Instance)
  7. 10.7Nested Types (Static and Instance)

11.Object Inheritance and Interfaces

  1. 11.1A Better Example
  2. 11.2A Little Polymorphism
  3. 11.3Sealed
  4. 11.4Abstract Classes and Members
  5. 11.5Interfaces
  6. 11.6Overriding Sealed Members
  7. 11.7Coming Full Circle
  8. 11.8Providing a Default Implementation

12.Creating Value Types

  1. 12.1Enumerations
  2. 12.2Flags
  3. 12.3String Library
  4. 12.4Structs
  5. 12.5Equals and GetHashCode
  6. 12.6Useful Framework Structs

13.Using Generics

  1. 13.1What is a generic?
  2. 13.2List<T>
  3. 13.3Rant on a Tangent
  4. 13.4Back to List<T>
  5. 13.5Sorting a List
  6. 13.6Dictionary<TKey, TValue>

14.Creating Generics

  1. 14.1Lambdas and Delegates
  2. 14.2Action<T>
  3. 14.3Func<T, TResult>
  4. 14.4Generic Methods
  5. 14.5Generic Type Constraints
  6. 14.6A Real Example
  7. 14.7Recursive Methods
  8. 14.8Continuing with Our Example

15.Fluent APIs and LINQ

  1. 15.1Fluent APIs
  2. 15.2LINQ, Lamba-style

16.Miscellaneous Language Features

  1. 16.1ValueTuple
  2. 16.2?

17.Basic I/O

18.Reflection

Visual Studio Quickstart - Windows

Reusable .NET Components

  1. Frameworks on Frameworks
  2. NuGet

C# Version History

  1. Prognostication

Recommended Reading

My Personal Coding Style

Legal Matter

Colophon

About the Author

The Leanpub 60 Day 100% Happiness Guarantee

Within 60 days of purchase you can get a 100% refund on any Leanpub purchase, in two clicks.

Now, this is technically risky for us, since you'll have the book or course files either way. But we're so confident in our products and services, and in our authors and readers, that we're happy to offer a full money back guarantee for everything we sell.

You can only find out how good something is by trying it, and because of our 100% money back guarantee there's literally no risk to do so!

So, there's no reason not to click the Add to Cart button, is there?

See full terms...

Earn $8 on a $10 Purchase, and $16 on a $20 Purchase

We pay 80% royalties on purchases of $7.99 or more, and 80% royalties minus a 50 cent flat fee on purchases between $0.99 and $7.98. You earn $8 on a $10 sale, and $16 on a $20 sale. So, if we sell 5000 non-refunded copies of your book for $20, you'll earn $80,000.

(Yes, some authors have already earned much more than that on Leanpub.)

In fact, authors have earned over $14 million writing, publishing and selling on Leanpub.

Learn more about writing on Leanpub

Free Updates. DRM Free.

If you buy a Leanpub book, you get free updates for as long as the author updates the book! Many authors use Leanpub to publish their books in-progress, while they are writing them. All readers get free updates, regardless of when they bought the book or how much they paid (including free).

Most Leanpub books are available in PDF (for computers) and EPUB (for phones, tablets and Kindle). The formats that a book includes are shown at the top right corner of this page.

Finally, Leanpub books don't have any DRM copy-protection nonsense, so you can easily read them on any supported device.

Learn more about Leanpub's ebook formats and where to read them

Write and Publish on Leanpub

You can use Leanpub to easily write, publish and sell in-progress and completed ebooks and online courses!

Leanpub is a powerful platform for serious authors, combining a simple, elegant writing and publishing workflow with a store focused on selling in-progress ebooks.

Leanpub is a magical typewriter for authors: just write in plain text, and to publish your ebook, just click a button. (Or, if you are producing your ebook your own way, you can even upload your own PDF and/or EPUB files and then publish with one click!) It really is that easy.

Learn more about writing on Leanpub