Part I of this book concentrates on the C# language. Part II details how to write .NET programs, and Part III describes how to use C# with the .NET Common Language Runtime library.
Chapter 1, introduces you to the C# language and the .NET platform.
Chapter 2 demonstrates a simple program, to provide a context for what follows, and introduces you to the Visual Studio IDE and a number of C# language concepts.
Chapter 3, presents the basics of the language, from built-in data types to keywords.
Classes define new types and allow the programmer to extend the language so that you can better model the problem you’re trying to solve. Chapter 4, explains the components that form the heart and soul of C#.
Classes can be complex representations and abstractions of things in the real world. Chapter 5, discusses how classes relate and interact.
Chapter 6, teaches you how to add operators to your user-defined types.
Chapter 7 and Chapter 8 introduce Structs and Interfaces, respectively, both close cousins to classes. Structs are lightweight objects, more restricted than classes, that make fewer demands on the operating system and on memory. Interfaces are contracts; they describe how a class will work so that other programmers can interact with your objects in well-defined ways.
Object-oriented programs often create a great many objects. It is convenient to group these objects and manipulate them together, and C# provides extensive support for collections. Chapter 9, explores the collection classes provided by the Base Class Library and how to create your own collection types as well.
Chapter 10 discusses how you can use C# to manipulate text Strings and Regular Expressions. Most Windows and web programs interact with the user, and strings play a vital role in the user interface.
Chapter 11, explains how to deal with exceptions, which provide an object-oriented mechanism for handling life’s little emergencies.
Both Windows and web applications are event-driven. In C#, events are first-class members of the language. Chapter 12, focuses on how events are managed, and how delegates, object-oriented type-safe callback mechanisms, are used to support event handling.
This section and the next will be of interest to all readers, no matter how much experience you may already have with other programming languages. These sections explore the details of the .NET platform.
Part II details how to write .NET programs: both desktop applications with Windows Forms and web applications with Web Forms. In addition, Part II describes database interactivity and how to create web services.
On top of this infrastructure sits a high-level abstraction of the operating system, designed to facilitate object-oriented software development. This top tier includes ASP.NET and Windows Forms. ASP.NET includes both Web Forms, for rapid development of web applications, and Web Services, for creating web objects with no user interface.
C# provides a Rapid Application Development (RAD) model similar to that previously available only in Visual Basic. Chapter 13, describes how to use this RAD model to create professional-quality Windows programs using the Windows Forms development environment.
Whether intended for the Web or for the desktop, most applications depend on the manipulation and management of large amounts of data. Chapter 14, explains the ADO.NET layer of the .NET Framework and explains how to interact with Microsoft SQL Server and other data providers.
Chapter 15 combines the RAD techniques demonstrated in Chapter 13 with the data techniques from Chapter 14 to demonstrate Building Web Applications with Web Forms.
Not all applications have a user interface. Chapter 16 focuses on the second half of ASP.NET technology: Web Services. A web service is a distributed application that provides functionality via standard web protocols, most commonly XML and HTTP.
A runtime is an environment in which programs are executed. The Common Language Runtime (CLR) is the heart of .NET. It includes a data typing system which is enforced throughout the platform and which is common to all languages developed for .NET. The CLR is responsible for processes such as memory management and reference counting of objects.
Another key feature of the .NET CLR is garbage
collection
. Unlike with traditional C/C++ programming, in
C# the developer is not responsible for destroying objects. Endless
hours spent searching for memory leaks are a thing of the past; the
CLR cleans up after you when your objects are no longer in use. The
CLR’s garbage collector checks the heap for unreferenced
objects and frees the memory used by these objects.
The .NET platform and class library extends upward into the middle-level platform, where you find an infrastructure of supporting classes, including types for interprocess communication, XML, threading, I/O, security, diagnostics, and so on. The middle tier also includes the data-access components collectively referred to as ADO.NET that are discussed in Chapter 14.
Part III of this book discusses the relationship of C# to the Common Language Runtime and the Base Class Library.
Chapter 17, distinguishes between private and public assemblies and describes how assemblies are created and managed. In .NET, an assembly is a collection of files that appears to the user to be a single DLL or executable. An assembly is the basic unit of reuse, versioning, security, and deployment.
.NET assemblies include extensive metadata about classes, methods, properties, events, and so forth. This metadata is compiled into the program and retrieved programmatically through reflection. Chapter 18, explores how to add metadata to your code, how to create custom attributes, and how to access this metadata through reflection. It goes on to discuss dynamic invocation, in which methods are invoked with late (runtime) binding, and ends with a demonstration of reflection emit, an advanced technique for building self-modifying code.
The .NET Framework was designed to support web-based and distributed applications. Components created in C# may reside within other processes on the same machine or on other machines across the network or across the Internet. Marshaling is the technique of interacting with objects that aren’t really there, while remoting comprises techniques for communicating with such objects. Chapter 19, elaborates.
The Base Class Libraries provide extensive support for asynchronous I/O and other classes that make explicit manipulation of threads unnecessary. However, C# does provide extensive support for Threads and Synchronization, discussed in Chapter 20.
Chapter 21 discusses Streams, a mechanism not only for interacting with the user but also for retrieving data across the Internet. This chapter includes full coverage of C# support for serialization: the ability to write an object graph to disk and read it back again.
Chapter 22, explores interoperability—the ability to interact with COM components created outside the managed environment of the .NET Framework. It is possible to call components from C# applications into COM and to call components from COM into C#. Chapter 22 describes how this is done.
The book concludes with an appendix of C# Keywords.
Get Programming C# now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.