expert c 5.0, Complete IT Books Pack
[ Pobierz całość w formacie PDF ]
              For your convenience Apress has placed some of the front
matter material after the index. Please use the Bookmarks
and Contents at a Glance links to access them.
Contents at a Glance
n
About the Author .................................................................................................................
n
About the Technical Reviewer ...........................................................................................
n
Acknowledgments ..............................................................................................................
n
Chapter 1: Reintroducing C#:-A Detailed Look at the Language We All Know ...................
n
Chapter 2: C# Objects in Memory .......................................................................................
n
Chapter 3: Parameters ......................................................................................................
n
Chapter 4: Methods ...........................................................................................................137
n
Chapter 5: Automatic Property Declaration......................................................................
n
Chapter 6: Enum ................................................................................................................
n
Chapter 7: Delegate ...........................................................................................................187
n
Chapter 8: Event ................................................................................................................213
n
Chapter 9: Foreach and Iterator ........................................................................................
n
Chapter 10: The String Data Type ....................................................................................
n
Chapter 11: Collections Explained ...................................................................................
n
Chapter 12: Linq in C# .......................................................................................................349
n
Chapter 13: Exception Management .................................................................................
n
Chapter 14: Asynchrony ....................................................................................................497
n
Chapter 15: Diagnostic Tools in .NET ................................................................................
n
Index ..................................................................................................................................
iii
Acknowledgments
It has been a long journey writing this book, and I want to thank many people, especially my acquisition
editor, Ewan Buckingham, from Apress, who made publication of this book possible. Every person at
Apress who was involved with this book did an excellent job, and I thank them all. I would especially like to
express my appreciation to my development editor, Jonathan Hassell, as well as James Markham, who gave
me many great suggestions and improved the quality of the book. I also thank my copy editor, Mary
Bearden, who did a great job editing this book. I also express my thanks to my coordinating editor, Katie
Sullivan. Lastly and most importantly, I thank my technical editor, Todd Meister, who did a fabulous job
and provided many excellent suggestions.
Looking back on this year, when I was writing articles for the codeproject.com, a few members
suggested that I should write a book. Especially Sander Rossel, who recommended I get in touch with
Apress. Marcelo Oliveira is another member from codeproject.com who inspired me to write this book. My
thanks to both Sander and Marcelo.
I also give special thanks to my parents for their support and best wishes through this process. I also
thank my sister and sister-in-law. Lastly, I am grateful to my wife for her support, passion, and
understanding and for letting me work late nights and over weekends.
xiv
 CHAPTER 1
n n n
Reintroducing C#:-A Detailed Look
at the Language We All Know
This chapter will discuss the basics of the C# language. It begins with an example of a square number
generator program to explain the basic structure of a C# program, how the C# compiles a C# program, and
then explains Just-in-Time compilation. You will learn about the lexical element of the C# language,
different types such as value and reference types, variables, parameters, and statements, and about the
interface
,
enum
, and
delegate
classes.
Square Number Using the C#
Listing 1-1 shows a simple program that calculates the square of a given number and displays the squared
number as output.
Listing 1-1.
Square Number Program
using System;
/* importing namespace */
namespace Ch01
/* namespace declaration */
{
class Program
/* class declaration*/
{
static void Main(string[] args)
/* method declaration */
{
PowerGenerator pg = new PowerGenerator();
pg.ProcessPower();
}
/* end of method declaration */
}
/* end of class declaration */
public class PowerGenerator
{
const int limit = 3;
/* constant declaration */
const string
original = "Original number",
1
Â
[ Pobierz całość w formacie PDF ]