Step-by-step beginner's guide to Visual C# 2012
Written for novice programmers who want to learn programming with C# and the .NET framework, this book offers programming basics such as variables, flow control, and object oriented programming. It then moves into web and Windows programming and data access (databases and XML). The authors focus on the tool that beginners use most often to program C#, the Visual C# 2012 development environment in Visual Studio 2012.
- Puts the spotlight on key beginning level topics with easy-to-follow instructions for Microsoft Visual C# 2012
- Explores how to program for variables, expressions, flow control, and functions
- Explains the debugging process and error handling as well as object oriented programming, and much more
Beginning Microsoft Visual C# 2012 Programming offers beginners a guide to writing effective programming code following simple step-by-step methods, each followed by the opportunity to try out newly acquired skills.
Autorentext
Karli Watson is an author and IT contractor in London.
Jacob Vibe Hammer is a software architect and developer at Kamstrup A/S, Denmark. He has coauthored several books.
Jon D. Reid is the director of systems engineering at Indigo Biosystems, Inc.
Morgan Skinner joined Microsoft in 2001.
Daniel Kemper is a software engineer specializing in reporting and rich client technologies.
Christian Nagel is a Microsoft Regional Director and Microsoft MVP, an associate of thinktecture, and founder of CN innovation.
Wrox Beginning guides are crafted to make learning programming languages and technologies easier than you think, providing a structured, tutorial format that will guide you through all the techniques involved.
Zusammenfassung
Step-by-step beginner's guide to Visual C# 2012
Written for novice programmers who want to learn programming with C# and the .NET framework, this book offers programming basics such as variables, flow control, and object oriented programming. It then moves into web and Windows programming and data access (databases and XML). The authors focus on the tool that beginners use most often to program C#, the Visual C# 2012 development environment in Visual Studio 2012.
- Puts the spotlight on key beginning level topics with easy-to-follow instructions for Microsoft Visual C# 2012
- Explores how to program for variables, expressions, flow control, and functions
- Explains the debugging process and error handling as well as object oriented programming, and much more
Beginning Microsoft Visual C# 2012 Programming offers beginners a guide to writing effective programming code following simple step-by-step methods, each followed by the opportunity to try out newly acquired skills.
Inhalt
INTRODUCTION xxxi
PART I: THE C# LANGUAGE
CHAPTER 1: INTRODUCING C# 3
What Is the .NET Framework? 3
What's in the .NET Framework? 4
Writing Applications Using the .NET Framework 4
CIL and JIT 4
Assemblies 5
Managed Code 5
Garbage Collection 6
Fitting It Together 6
Linking 7
What Is C#? 7
Applications You Can Write with C# 8
C# in this Book 8
Visual Studio 2012 8
Visual Studio Express 2012 Products 9
Solutions 9
Summary 10
CHAPTER 2: WRITING A C# PROGRAM 13
The Visual Studio 2012 Development Environment 14
Console Applications 16
The Solution Explorer 18
The Properties Window 19
The Error List Window 19
Desktop Applications 20
Summary 23
CHAPTER 3: VARIABLES AND EXPRESSIONS 25
Basic C# Syntax 26
Basic C# Console Application Structure 28
Variables 29
Simple Types 29
Variable Naming 33
Naming Conventions 34
Literal Values 34
Variable Declaration and Assignment 36
Expressions 37
Mathematical Operators 37
Assignment Operators 41
Operator Precedence 42
Namespaces 42
Summary 45
CHAPTER 4: FLOW CONTROL 49
Boolean Logic 49
Boolean Assignment Operators 52
Bitwise Operators 53
Operator Precedence Updated 57
The goto Statement 58
Branching 59
The Ternary Operator 59
The if Statement 59
Checking More Conditions Using if Statements 62
The switch Statement 63
Looping 65
do Loops 66
while Loops 68
for Loops 70
Interrupting Loops 74
Infi nite Loops 75
Summary 75
CHAPTER 5: MORE ABOUT VARIABLES 79
Type Conversion 80
Implicit Conversions 80
Explicit Conversions 81
Explicit Conversions Using the Convert Commands 84
Complex Variable Types 86
Enumerations 87
Defi ning Enumerations 87
Structs 90
Defi ning Structs 90
Arrays 92
Declaring Arrays 93
foreach Loops 95
Multidimensional Arrays 96
Arrays of Arrays 97
String Manipulation 98
Summary 102
CHAPTER 6: FUNCTIONS 105
Defi ning and Using Functions 106
Return Values 108
Parameters 109
Parameter Matching 111
Parameter Arrays 111
Reference and Value Parameters 113
Out Parameters 115
Variable Scope 116
Variable Scope in Other Structures 118
Parameters and Return Values versus Global Data 120
The Main( ) Function 121
Struct Functions 123
Overloading Functions 124
Using Delegates 125
Summary 128
CHAPTER 7: DEBUGGING AND ERROR HANDLING 131
Debugging in Visual Studio 132
Debugging in Nonbreak (Normal) Mode 132
Outputting Debugging Information 133
Tracepoints 137
Diagnostics Output Versus Tracepoints 139
Debugging in Break Mode 140
Entering Break Mode 140
Monitoring Variable Content 142
Stepping Through Code 144
Immediate and Command Windows 146
The Call Stack Window 146
Error Handling 147
try...catch...finally 147
Listing and Configuring Exceptions 152
Notes on Exception Handling 152
Summary 153
CHAPTER 8: INTRODUCTION TO OBJECT-ORIENTED
PROGRAMMING 157
What Is Object-Oriented Programming? 158
What Is an Object? 158
Properties and Fields 159
Methods 160
Everything's an Object 161
The Life Cycle of an Object 161
Constructors 161
Destructors 162
Static and Instance Class Members 162
Static Constructors 162
Static Classes 163
OOP Techniques 163
Interfaces 163
Disposable Objects 164
Inheritance 165
Polymorphism 167
Interface Polymorphism 168
Relationships Between Objects 168
Containment 168
Collections 169
Operator Overloading 169
Events 170
Reference Types Versus Value Types 170
OOP in Desktop Applications 171
Summary 174
CHAPTER 9: DEFINING CLASSES 177
Class Defi nitions in C# 177
Interface Defi nitions 180
System.Object 182
Constructors and Destructors 184
Constructor Execution Sequence 185
OOP Tools in Visual Studio 188
The Class View Window 188
The Object Browser 190
Adding Classes 191
Class Diagrams 192
Class Library Projects 193
Interfaces Versus Abstract Classes 196
Struct Types 198
Shallow Copying Versus Deep Copying 200
Summary 200
CHAPTER 10: DEFINING CLASS MEMBERS 203
Member Defi nitions 203
Defi ning Fields 204
Defi ning Methods 204
Defi ning Properties 205
Adding Members from …