Skip to main content

2018 | Buch

Illustrated C# 7

The C# Language Presented Clearly, Concisely, and Visually

insite
SUCHEN

Über dieses Buch

Get to work quickly with C# with a uniquely succinct and visual format used to present the C# 7.0 language. Whether you’re getting to grips with C# for the first time or working to deepen your understanding, you’ll find this book to be a clear and refreshing take on each aspect of the language.

Figures are of prime importance in this book. While teaching programming seminars, Daniel Solis found that he could almost watch the light bulbs going on over the students’ heads as he drew the figures on the whiteboard. In this text, he has distilled each important concept into simple but accurate illustrations. For this latest edition, Dan is joined by fellow experienced teacher and programmer, Cal Schrotenboer, to bring you the very latest C# language features, along with an understanding of the frameworks it most often lives in: .NET and the new .NET Core.

For something as intricate and precise as a programming language, there must be text as well as figures. But rather than long, wordy explanations, the authors use short, concise descriptions and bullet lists to make each important piece of information visually distinct and memorable.

What You’ll Learn

Start with an overview of C# programming and how the language works under the hood

Put things in context with a little useful history of C# and .NET

Know how .NET Core fits into the picture

Understand how C# handles typesBenefit from clear, concise explanations of each language feature, from classes and inheritance to enumerators and iterators, and the new C# 7.0 tuplesQuickly access material via this book's visual introduction to asynchronous programming with C#

Who This Book Is For

Novice to intermediate C# programmers, and more experienced programmers moving to C# from other languages

Inhaltsverzeichnis

Frontmatter
Chapter 1. C# and the .NET Framework
Abstract
The C# programming language was designed for developing programs for Microsoft’s .NET Framework. This chapter gives a brief look at where .NET came from and its basic architecture. To start off, let’s get the name right: C# is pronounced “see sharp.”
Daniel Solis, Cal Schrotenboer
Chapter 2. C# and .NET Core
Abstract
The .NET Framework was originally released in 2002. In terms of programming frameworks, that makes it “mature” in the sense that it contains virtually every significant, desirable feature currently available in major programming languages. Nevertheless, it would be a mistake to think that .NET has reached “old age”; “middle aged” would be a much closer description. After all, C and C++ have been around for far longer than C#.
Daniel Solis, Cal Schrotenboer
Chapter 3. Overview of C# Programming
Abstract
This chapter lays the groundwork for studying C#. Since we’ll use code samples extensively throughout the text, we first need to show you what a C# program looks like and what its various parts mean.
Daniel Solis, Cal Schrotenboer
Chapter 4. Types, Storage, and Variables
Abstract
If you were to broadly characterize the source code of C and C++ programs, you might say that a C program is a set of functions and data types and that a C++ program is a set of functions and classes. A C# program, however, is a set of type declarations.
Daniel Solis, Cal Schrotenboer
Chapter 5. Classes: The Basics
Abstract
In the previous chapter, you saw that C# provides six user-defined types. The most important of these, and the one we’ll cover first, is the class. Since the topic of classes in C is a large one, we’ll spread its discussion over the next several chapters.
Daniel Solis, Cal Schrotenboer
Chapter 6. Methods
Abstract
A method is a block of code with a name. You can execute the code from somewhere else in the program by using the method’s name. You can also pass data into a method and receive data back as output.
Daniel Solis, Cal Schrotenboer
Chapter 7. More About Classes
Abstract
The previous two chapters covered two of the nine types of class members: fields and methods. In this chapter, we’ll introduce all the other class members except events and operators and explain their features. We’ll cover events in Chapter 15.
Daniel Solis, Cal Schrotenboer
Chapter 8. Classes and Inheritance
Abstract
Inheritance allows you to define a new class that incorporates and extends an already declared class.
Daniel Solis, Cal Schrotenboer
Chapter 9. Expressions and Operators
Abstract
This chapter defines expressions and describes the operators provided by C#. It also explains how you can define the C# operators to work with your user-defined classes.
Daniel Solis, Cal Schrotenboer
Chapter 10. Statements
Abstract
The statements in C# are similar to those of C and C++. This chapter covers the characteristics of the C# statements, as well as the flow-of-control statements provided by the language.
Daniel Solis, Cal Schrotenboer
Chapter 11. Structs
Abstract
Structs are programmer-defined data types, similar to classes. They have data members and function members. Although structs are similar to classes, there are a number of important differences. The most important ones are the following:
Daniel Solis, Cal Schrotenboer
Chapter 12. Enumerations
Abstract
An enumeration, or enum, is a programmer-defined type, such as a class or a struct.
Daniel Solis, Cal Schrotenboer
Chapter 13. Arrays
Abstract
An array is a set of uniform data elements represented by a single variable name. The individual elements are accessed using the variable name together with one or more indexes between square brackets, as shown here:
Daniel Solis, Cal Schrotenboer
Chapter 14. Delegates
Abstract
You can think of a delegate as an object that holds one or more methods. Normally, of course, you wouldn’t think of “executing” an object, but a delegate is different from a typical object. You can execute a delegate, and when you do so, it executes the method or methods that it “holds.”
Daniel Solis, Cal Schrotenboer
Chapter 15. Events
Abstract
One common requirement in many programs is that when a particular program event occurs, other parts of the program need to be notified that the event has occurred.
Daniel Solis, Cal Schrotenboer
Chapter 16. Interfaces
Abstract
This description sounds pretty abstract, so we’ll first show you the problem that an interface helps solve, as well as how it solves it.
Daniel Solis, Cal Schrotenboer
Chapter 17. Conversions
Abstract
The .NET Framework was originally released in 2002. In terms of programming frameworks, that makes it “mature” in the sense that it contains virtually every significant, desirable feature currently available in major programming languages. Nevertheless, it would be a mistake to think that .NET has reached “old age”; “middle aged” would be a much closer description. After all, C and C++ have been around for far longer than C#.
Daniel Solis, Cal Schrotenboer
Chapter 18. Generics
Abstract
With the language constructs you’ve learned so far, you can build powerful objects of many different types. You do this mostly by declaring classes that encapsulate the behavior you want and then creating instances of those classes.
Daniel Solis, Cal Schrotenboer
Chapter 19. Enumerators and Iterators
Abstract
In Chapter 13, you saw that you can use a foreach statement to cycle through the elements of an array. In this chapter, you’ll take a closer look at arrays and see why they can be processed by foreach statements. You’ll also look at how you can add this capability to your own user-defined classes, using iterators.
Daniel Solis, Cal Schrotenboer
Chapter 20. Introduction to LINQ
Abstract
In a relational database system, data is organized into nicely normalized tables and accessed with a simple but powerful query language—SQL. SQL can work with any set of data in a database because the data is organized into tables, following strict rules.
Daniel Solis, Cal Schrotenboer
Chapter 21. Introduction to Asynchronous Programming
Abstract
When you start a program, the system creates a new process in memory. A process is the set of resources that comprise a running program. These include the virtual address space, file handles, and a host of other things required for the program to run.
Daniel Solis, Cal Schrotenboer
Chapter 22. Namespaces and Assemblies
Abstract
In Chapter 1, you took a high-level look at the compilation process. You saw that the compiler takes the source code file and produces an output file called an assembly. This chapter takes a closer look at assemblies and how they are produced and deployed. It also covers how namespaces help organize types.
Daniel Solis, Cal Schrotenboer
Chapter 23. Exceptions
Abstract
An exception is a runtime error in a program that violates a system or application constraint, or a condition that is not expected to occur during normal operation. Examples are when a program tries to divide a number by zero or tries to write to a read-only file. When these occur, the system catches the error and raises an exception.
Daniel Solis, Cal Schrotenboer
Chapter 24. Preprocessor Directives
Abstract
The source code specifies the definition of a program. The preprocessor directives instruct the compiler how to treat the source code. For example, under certain conditions, you might want the compiler to ignore portions of the code, and under other conditions, you might want that code compiled. The preprocessor directives give you those options and several others.
Daniel Solis, Cal Schrotenboer
Chapter 25. Reflection and Attributes
Abstract
Most programs are written to work on data. They read, write, manipulate, and display data. (Graphics are a form of data.) For some types of programs, however, the data they manipulate is not numbers, text, or graphics, but information about programs and program types.
Daniel Solis, Cal Schrotenboer
Chapter 26. What’s New in C# 6 and 7
Abstract
This chapter summarizes the changes made to the C# language since the previous revision of this book, which covered C# up through version 5.0. Most of these changes, however, are enhancements to existing functionality or alternate syntax for expressing a given construct in a slightly different manner. Therefore, understanding these changes requires an understanding of the existing functionality of the current syntax.
Daniel Solis, Cal Schrotenboer
Chapter 27. Other Topics
Abstract
In this chapter, we’ll cover a number of other topics that are important in using C# but that don’t fit neatly into one of the other chapters. These include string handling, nullable types, the Main method, documentation comments, and nested types.
Daniel Solis, Cal Schrotenboer
Backmatter
Metadaten
Titel
Illustrated C# 7
verfasst von
Daniel Solis
Cal Schrotenboer
Copyright-Jahr
2018
Verlag
Apress
Electronic ISBN
978-1-4842-3288-0
Print ISBN
978-1-4842-3287-3
DOI
https://doi.org/10.1007/978-1-4842-3288-0