C# 7.0 in a Nutshell_ The Definitive Reference-O’Reilly Media (2017).pdf

(8976 KB) Pobierz
C# 7
.0
in a Nutshell
THE DEFINITIVE REFERENCE
Joseph Albahari & Ben Albahari
Co
2
on
ard
iti
nd
Ed
ta
h
TS
7 t
.NE
ve
rs
C# 7.0
IN A NUTSHELL
Joseph Albahari and Ben Albahari
C# 7.0 in a Nutshell
by Joseph Albahari and Ben Albahari
Copyright © 2018 Joseph Albahari, Ben Albahari. All rights reserved.
Printed in the United States of America.
Published by O’Reilly Media, Inc., 1005 Gravenstein Highway North, Sebastopol, CA 95472.
O’Reilly books may be purchased for educational, business, or sales promotional use. Online
editions are also available for most titles (http://oreilly.com/safari). For more information,
contact our corporate/institutional sales department: 800-998-9938 or
corporate@oreilly.com.
Editors:
Rachel Roumeliotis
Production Editor:
Colleen Cole
Copyeditor:
Jasmine Kwityn
Proofreader:
Kim Cofer
October 2017:
First Edition
Indexer:
Judith McConville
Interior Designer:
David Futato
Cover Designer:
Karen Montgomery
Illustrator:
Rebecca Demarest
Revision History for the First Edition
2017-10-03:
2017-11-03:
First Release
Second Release
See
http://oreilly.com/catalog/errata.csp?isbn=9781491987650
for release details.
The O’Reilly logo is a registered trademark of O’Reilly Media, Inc.
C# 7.0 in a Nutshell,
the
cover image, and related trade dress are trademarks of O’Reilly Media, Inc.
While the publisher and the authors have used good faith efforts to ensure that the informa‐
tion and instructions contained in this work are accurate, the publisher and the authors dis‐
claim all responsibility for errors or omissions, including without limitation responsibility for
damages resulting from the use of or reliance on this work. Use of the information and
instructions contained in this work is at your own risk. If any code samples or other technol‐
ogy this work contains or describes is subject to open source licenses or the intellectual prop‐
erty rights of others, it is your responsibility to ensure that your use thereof complies with
such licenses and/or rights.
978-1-491-98765-0
[M]
Table of Contents
Preface. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xi
1. Introducing C# and the .NET Framework. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1
Object Orientation
Type Safety
Memory Management
Platform Support
C# and the CLR
The CLR and .NET Framework
Other Frameworks
A Brief History of C#
A First C# Program
Syntax
Type Basics
Numeric Types
Boolean Type and Operators
Strings and Characters
Arrays
Variables and Parameters
Expressions and Operators
Null Operators
Statements
Namespaces
Classes
Inheritance
The object Type
1
2
3
3
3
4
5
8
2. C# Language Basics. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
15
18
21
30
37
39
42
46
56
60
62
71
3. Creating Types in C#. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 79
79
96
105
iii
Zgłoś jeśli naruszono regulamin