SPECIAL OFFERS
Keep up with new releases and promotions. Sign up to hear from us.
Rough Cuts are manuscripts that are developed but not yet published, available through Safari. Rough Cuts provide you access to the very latest information on a given topic and offer you the opportunity to interact with the author to influence the final publication.
This is the Rough Cut version of the printed book.
Essential C# 5.0 is a well-organized, no-fluff guide to the latest versions of C# for programmers at all levels of C# experience. Fully updated to reflect new features and programming patterns introduced with C# 5.0 and .NET 4.5, this guide shows you how to write C# code that is simple, powerful, robust, secure, and maintainable. Microsoft MVP Mark Michaelis and C# principal developer Eric Lippert provide comprehensive coverage of the entire language, offering a complete foundation for effective software development.The authors illustrate key constructs with succinct, downloadable code examples. Graphical mind maps at the beginning of each chapter outline the material that is covered and how individual topics interrelate. This edition also includes C# Coding Guidelines that call attention to today’s best practices for writing C# code. Separate indexes of C# versions 3.0, 4.0, and 5.0 make it easy to find answers specific to whatever version of C# you are using.
Throughout, topics intended for beginners and advanced readers are clearly marked. If you’re new to C#, this guide will help you start writing significant code quickly. If you’re an experienced C# developer, you’ll gain insight into today’s most complex programming challenges and techniques as you master key C# 5.0 innovations such as async/await pattern. No matter how advanced your skills become, you’ll come to rely on this indispensable reference.
Coverage includes
Figures xv
Tables xvii
Foreword xix
Preface xxiii
Acknowledgments xxxv
About the Authors xxxvii
Chapter 1: Introducing C# 1
Hello, World 2
C# Syntax Fundamentals 4
Console Input and Output 17
Chapter 2: Data Types 33
Fundamental Numeric Types 34
More Fundamental Types 43
null and void 53
Categories of Types 57
Nullable Modifier 60
Conversions between Data Types 60
Arrays 67
Chapter 3: Operators and Control Flow 85
Operators 86
Introducing Flow Control 103
Code Blocks ({}) 110
Code Blocks, Scopes, and Declaration Spaces 112
Boolean Expressions 114
Bitwise Operators (<<, >>, |, &, ^, ~) 121
Control Flow Statements, Continued 127
Jump Statements 139
C# Preprocessor Directives 145
Chapter 4: Methods and Parameters 155
Calling a Method 156
Declaring a Method 163
The using Directive 168
Returns and Parameters on Main() 172
Advanced Method Parameters 175
Recursion 184
Method Overloading 186
Optional Parameters 189
Basic Error Handling with Exceptions 194
Chapter 5: Classes 209
Declaring and Instantiating a Class 213
Instance Fields 217
Instance Methods 219
Using the this Keyword 220
Access Modifiers 227
Properties 229
Constructors 244
Static Members 255
Extension Methods 265
Encapsulating the Data 267
Nested Classes 269
Partial Classes 272