Back to description
The .NET Framework is a development framework created by Microsoft to enable developers to build applications that run on... more
The .NET Framework is a development framework created by Microsoft to enable developers to build applications that run on Microsoft (and other) platforms. Understanding the basics of the .NET Framework is essential because a large part of C# development revolves around using the classes in that framework.
This chapter explains the key components in the .NET Framework as well as the role played by each of the components. In addition, it examines the relationships between the various versions of the Framework, from version 1.0 to the latest 3.5.
... less
Microsoft Visual Studio 2008 is an extremely versatile and powerful environment for developing .NET applications. This chapter... more
Microsoft Visual Studio 2008 is an extremely versatile and powerful environment for developing .NET applications. This chapter explores some of the commonly used features that you will likely use in the process of your development work. Because there are literally hundreds and thousands of ways in which you can customize Visual Studio 2008, this chapter can only explore, for the most part, the default settings in Visual Studio. While some of the topics covered are discussed in more detail in subsequent chapters, you’ll want to breeze through this chapter to get an overall look at this version of Visual Studio.
This chapter examines:
Components of the IDE (Menu bar, Toolbar, Toolbox, and so on)
Code and Text Editor and the features it contains, including IntelliSense and Refactoring support
Using the debugger in Visual Studio 2008
Unit testing in Visual Studio 2008
The best way to get started in a new programming language is to create a simple program and then examine the various parts... more
The best way to get started in a new programming language is to create a simple program and then examine the various parts that compose it. With this principle in mind, you’ll create a simple C# programfirst using Visual Studio 2008 and then using a plain text editor.
In this chapter you build and run the HelloWorld application, using Visual Studio 2008 as well as using the command line. After that, you tackle the syntax of the C# language and all the important topics, such as:
C# keywords
Variables
Constants
Comments
XML documentation
Data types
Flow control
Loops
Operators
Preprocessor directives
One of the most important topics in C# programmingin fact, the cornerstone of .NET developmentis classes and objects.... more
One of the most important topics in C# programmingin fact, the cornerstone of .NET developmentis classes and objects.
Classes are essentially templates from which you create objects. In C# .NET programming, everything you deal with involves classes and objects. This chapter assumes that you already have a basic grasp of object-oriented programming. It tackles:
How to define a class
How to create an object from a class
The different types of members in a class
The root of all objectsSystem.Object
When defining a class, you have to provide the implementation for all its methods and properties. However, there are times... more
When defining a class, you have to provide the implementation for all its methods and properties. However, there are times when you do not want to provide the actual implementation of how a class might work. Rather, you want to describe the functionalities of the class. This set of descriptions is like a contract, dictating what the class will do, the types of parameters needed, and the type of return results. In object-oriented programming, this contract is known as an interface.
An interface defines a class and its members without providing any implementation. When using interfaces in programming, generally three parties are involved:
Interface definitionThe interface defines the composition of a class, such as methods, properties, and so on. However, the interface does not provide any implementation for any of these members.
Implementing classThe class that implements a particular interface provides the implementation for all the members defined in that interface.
ClientsObjects that instantiates from the implementing classes are known as the client. The client invokes the methods defined in the interface, whose implementation is provided by the implementing class.
Differences between an Interface and an Abstract Base Class
Conceptually, an abstract class is similar to an interface; however, they do have some subtle differences:
•An abstract class can contain a mixture of concrete methods (implemented) and abstract methods (an abstract class needs at least one abstract method); an interface does not contain any method implementations.
•An abstract class can contain constructors and destructors; an interface does not.
•A class can implement multiple interfaces, but it can inherit from only one abstract class.
This chapter explains how to define an interface and how to implement the interface using a class.
Inheritance is one of the fundamental concepts in object-oriented programming. Inheritance facilitates code reuse and allows... more
Inheritance is one of the fundamental concepts in object-oriented programming. Inheritance facilitates code reuse and allows you to extend the functionality of code that you have already written. This chapter looks at:
How inheritance works
Implementing inheritance in C#
Defining abstract methods and classes
Sealing classes and methods
Defining overloaded methods
The different types of access modifiers you can use in inheritance
Using inheritance in interfaces
Two of the most important aspects of object-oriented programming are delegates and events. A delegate basically enables you... more
Two of the most important aspects of object-oriented programming are delegates and events. A delegate basically enables you to reference a function without directly invoking the function. Delegates are often used to implement techniques called callbacks, which means that after a function has finished execution, a call is made to a specific function to inform it that the execution has completed. In addition, delegates are also used in event handling. Despite the usefulness of delegates, it is a topic that not all .NET programmers are familiar with. An event, on the other hand, is used by classes to notify clients when something of interest has happened. For example, a Button control has the Click even, which allows your program to be notified when someone clicks the button.
This chapter explores the following:
What is a delegate?
Using delegates
Implementing callbacks using a delegate
What are events?
How to handle and implement events in your program
One of the most common data types used in programming is the string. In C#, a string is a group of one or more characters... more
One of the most common data types used in programming is the string. In C#, a string is a group of one or more characters declared using the string keyword. Strings play an important part in programming and are an integral part of our livesour names, addresses, company names, email addresses, web site URLs, flight numbers, and so forth are all made up of strings. To help manipulate those strings and pattern matching, you use regular expressions, sequences of characters that define the patterns of a string. In this chapter, then, you will:
Explore the System.String class
Learn how to represent special characters in string variables
Manipulate strings with various methods
Format strings
Use the StringBuilder class to create and manipulate strings
Use Regular Expressions to match string patterns
One of the new features in the .NET Framework (beginning with version 2.0) is the support of generics in Microsoft Intermediate... more
One of the new features in the .NET Framework (beginning with version 2.0) is the support of generics in Microsoft Intermediate Language (MSIL). Generics use type parameters, which allow you to design classes and methods that defer the specification of one or more types until the class or method is declared and instantiated by client code. Generics enable developers to define type-safe data structures, without binding to specific fixed data types at design time.
Generics are a feature of the IL and not specific to C# alone, so languages such as C# and VB.NET can take advantage of them.
This chapter discusses the basics of generics and how you can use them to enhance efficiency and type safety in your applications. Specifically, you will learn:
Advantages of using generics
How to specify constraints in a generic type
Generic interfaces, structs, methods, operators, and delegates
The various classes in the .NET Framework class library that support generics
Today’s computer runs at more than 2GHz, a blazing speed improvement over just a few years ago. Almost all operating systems... more
Today’s computer runs at more than 2GHz, a blazing speed improvement over just a few years ago. Almost all operating systems today are multitasking, meaning you can run more than one application at the same time. However, if your application is still executing code sequentially, you are not really utilizing the speed advancements of your latest processor. How many times have you seen an unresponsive application come back to life after it has completed a background task such as performing some mathematical calculations or network transfer? To fully utilize the extensive processing power of your computer and write responsive applications, understanding and using threads is important.
A thread is a sequential flow of execution within a program. A program can consist of multiple threads of execution, each capable of independent execution.
This chapter explains how to write multithreaded applications using the Thread class in the .NET Framework. It shows you how to:
Create a new thread of execution and stop it
Synchronize different threads using the various thread classes available
Write thread-safe Windows applications
Use the BackgroundWorker component in Windows Forms to program background tasks.
At some stage in your development cycle, you need to store data on some persistent media so that when the computer is restarted... more
At some stage in your development cycle, you need to store data on some persistent media so that when the computer is restarted the data is still be available. In most cases, you either store the data in a database or in files. A file is basically a sequence of characters stored on storage media such as your hard disks, thumb drives, and so on. When you talk about files, you need to understand another associated termstreams. A stream is a channel in which data is passed from one point to another. In .NET, streams are divided into various types: file streams for files held on permanent storage, network streams for data transferred across the network, memory streams for data stored in internal storage, and so forth.
With streams, you can perform a wide range of tasks, including compressing and decompressing data, serializing and deserializing data, and encrypting and decrypting data. This chapter examines:
Manipulating files and directories
How to quickly read and write data to files
The concepts of streams
Using the BufferedStream class to improve the performance of applications reading from a stream.
BufferedStream
Using the FileStream class to read and write to files
FileStream
Using the MemoryStream class to use the internal memory store as a buffer
MemoryStream
Using the NetworkStream class for network programming
NetworkStream
The various types of cryptographic classes available in .NET.
Performing compressions and decompression on streams.
Serializing and deserializing objects into binary and XML data.
An exception is a situation that occurs when your program encounters an error that it is not expecting during runtime. Examples... more
An exception is a situation that occurs when your program encounters an error that it is not expecting during runtime. Examples of exceptions include trying to divide a number by zero, trying to write to a file that is read-only, trying to delete a nonexistent file, and trying to access more members of an array than it actually holds. Exceptions are part and parcel of an application, and as a programmer you need to look out for them by handling the various exceptions that may occur. That means your program must be capable of responding to the exceptions by offering some ways to remedy the problem instead of exiting midway through your program (that is, crashing).
In programming, you often need to work with collections of related data. For example, you may have a list of customers and... more
In programming, you often need to work with collections of related data. For example, you may have a list of customers and you need a way to store their email addresses. In that case, you can use an array to store the list of strings.
In .NET, there are many collection classes that you can use to represent groups of data. In addition, there are various interfaces that you can implement so that you can manipulate your own custom collection of data.
Declaring and initializing arrays
Declaring and using multidimensional arrays
Declaring a parameter array to allow a variable number of parameters in a function
Using the various System.Collections namespace interfaces
Using the different collection classes (such as Dictionary, Stacks, and Queue) in .NET
One of the most exciting new features in the .NET Framework v3.5 is the Language Integrated Query (LINQ). LINQ introduces... more
One of the most exciting new features in the .NET Framework v3.5 is the Language Integrated Query (LINQ). LINQ introduces to developers a standard and consistent language for querying and updating data, which include objects (such as arrays and collections), databases, XML documents, ADO.NET DataSets, and so forth.
Today, most developers need to know a myriad of technologies to successfully manipulate data. For example, if you are dealing with databases, you have to understand Structured Query Language (SQL). If you are dealing with XML documents, you must understand technologies such as XPath, XQuery, and XSLT. And if you are working with ADO.NET DataSets, then you need to know the various classes and properties in ADO.NET that you can use.
A better approach would be to have a unified view of the data, regardless of its form and structure. That is the motivation behind the design of LINQ. This chapter provides the basics of LINQ and shows how you can use LINQ to access objects, DataSets, and XML documents, as well as SQL databases.
In .NET, the basic unit deployable is called an assembly. Assemblies play an important part of the development process where... more
In .NET, the basic unit deployable is called an assembly. Assemblies play an important part of the development process where understanding how they work is useful in helping you develop scalable, efficient .NET applications. This chapter explores:
The components that make up a .NET assembly
The difference between single-file and multi-file assemblies
The relationships between namespaces and assemblies
The role played by the Global Assembly Cache (GAC)
How to develop a shared assembly, which can be shared by other applications
Chapters 16–19 each shows how you can use the C# language to create a different type of application. This chapter tackles... more
Chapters 16–19 each shows how you can use the C# language to create a different type of application. This chapter tackles Windows application development. The best way to learn a language is to actually work on a real project from the beginning to deployment. So, this chapter leads you through creating a Windows application that performs some useful tasks and then shows you how to deploy it using a technique in Visual Studio known as ClickOnce.
Specifically, the Windows application you build in this chapter demonstrates how to:
Programmatically access FTP servers using the FtpWebRequest and FtpWebResponse classes (both derived from the WebRequest and WebResponse classes in the System.Net namespace)
Incorporate printing capability in your Windows application using the PrintDocument class (located in the System.Drawing.Printing namespace)
Deploy a Windows application using ClickOnce. You will also see how to programmatically cause an application to update itself.
ASP.NET (Active Server Pages .NET) is a web development technology from Microsoft. Part of the .NET Framework, ASP.NET enables... more
ASP.NET (Active Server Pages .NET) is a web development technology from Microsoft. Part of the .NET Framework, ASP.NET enables developers to build dynamic web applications and Web Services using compiled languages like VB.NET and C#. Developers can use Visual Studio 2008 to develop compelling web applications using ASP.NET, with the ease of drag-and-drop server controls. The latest version of ASP.NET is version 3.5.
This chapter explains how to:
Display database records using a server control call GridView
GridView
Perform data binding in an ASP.NET application using the new LinqDataSource control
LinqDataSource
AJAX-enable your application by using the new AJAX framework in ASP.NET 3.5 and the AJAX Control Toolkit
Deploy your web application to a web server
The mobile application platform has gained a lot of interest among enterprise developers in recent years. With so many mobile... more
The mobile application platform has gained a lot of interest among enterprise developers in recent years. With so many mobile platforms available, customers are spoiled for choice. However, at the front of developers’ minds are the various criteria that they need to evaluate before deciding on the platform to support. These factors are:
Size of device install base
Ease of development and support for widely known/used programming languages
Capability to run one version of an application on a large number of devices
One mobile platform of choice among developers is the Microsoft Windows Mobile platform, now into its sixth generation. Today, the Windows Mobile platform is one of the most successful mobile device platforms in the market, with several handset manufacturers (such as HP, Asus, HTC, and even Sony Ericsson and Palm) supporting it.
This chapter presents the basics of Windows Mobile. It shows you how to create an RSS Reader application and then how to test and deploy the application to a real device. In particular, you will:
Examine the basics of the Windows Mobile platform
Learn how to download and install the various Software Development Kits (SDKs) to target the different platforms
Create an RSS Reader application that allows users to subscribe to RSS feeds
Explore various ways to deploy your Windows Mobile applications
Create a professional-looking setup application to distribute your Windows Mobile applications
Over the years, we have all seen the proliferation of web applications. In the early days, web sites consisted of sets of... more
Over the years, we have all seen the proliferation of web applications. In the early days, web sites consisted of sets of static HTML pages with nice graphics and lots of information. Then, server-side technologies like CGI, ASP, and JSP made web applications possible, and suddenly users could do a lot of things on the web, including buying products and making reservations online. Client-side innovations such as JavaScript helped improve the user experience of web applications, making them feel much more responsive. Although AJAX’s underlying technologies had been available for several years, it wasn’t really until the last couple of years that people really started spending more time AJAX-enabling their web applications. All this boils down to one important goal of web developersmaking web applications much more interactive and responsive.
Today, a new term has been coined: RIARich Internet Application. To Microsoft, RIA really stands for Rich Interactive Application. And it was with that in mind that Microsoft recently launched a new technology/product called Silverlight. Previously known as Windows Presentation Foundation/Everywhere (WPF/E), Microsoft Silverlight is a browser plug-in that enables developers to host RIAs that feature animation and vector graphics, as well as video playback.
This chapter will help you get started with Silverlight and provides an opportunity for you to get a feel for how Silverlight development works.
Windows Communication Foundation (WCF) is Microsoft’s unified programming model for building service oriented applications... more
Windows Communication Foundation (WCF) is Microsoft’s unified programming model for building service oriented applications (SOA). Parts of a service-oriented application can be exposed as a service that other applications can access.
WCF is a big topic, and it cannot be fully covered in a single chapter. However, this chapter provides a quick introduction to this new technology and shows how it addresses some of the limitations of today’s technology. While most books and conference focused heavily on the theory behind WCF, this chapter shows you how to build WCF services and then explains the theory behind them.
In short, this chapter explores:
How traditional ASMX Web Services differ from WCF
The ABCs of WCF
Building different types of WCF services
This appendix lists the various keywords in C# that are predefined and have special meanings for the compiler. It is important... more
This appendix lists the various keywords in C# that are predefined and have special meanings for the compiler. It is important to familiarize yourself with these keywords because they cannot be used as identifiers in your program. For example, this is a keyword in C# that is used to refer to the current instance of a class. Hence, this cannot be used as an identifier:
this
string this = "Hello, World"; //---error---
string
=
"Hello, World"
; //---error---
To use a keyword as an identifier, you need to prefix the keyword with the @ character. The following statement is valid:
@
string @this = "Hello, World"; //---ok---
; //---ok---
In C# 3.0, Microsoft introduces the concept of context keywords. Contextual keywords have special meaning in a particular context and can be used as an identifier outside the context. For example, the set and get contextual keywords are used as accessors in a property definition, together with the value keyword, like this:
In C# 3.0, Microsoft introduces the concept of context keywords. Contextual keywords have special meaning in a particular context and can be used as an identifier outside the context. For example, the
set
and
get
contextual keywords are used as accessors in a property definition, together with the
value
keyword, like this:
public class Point
public class
Point
{
Single _x;
Single
_x;
public Single x {
public
x {
get {
return _x;
}
set {
_x = value;
In this example, the get, set, and value contextual keywords have special meanings in a property definition (x). Using these contextual keywords within the property definition as identifiers is not valid. However, outside the property definition, you can use them as identifiers:
x
static void Main(string[] args)
static
void
Main(
[] args)
string get = "some string here...";
get =
"some string here..."
;
int set = 5;
int
set = 5;
double value = 5.6;
double
value = 5.6;
The beauty of contextual keywords is that as the C# language evolves, new keywords can be added to the language without breaking programs written using the earlier version of the language.
To be successful in .NET programming requires not only that you know the language you are using (C# in this case) but that... more
To be successful in .NET programming requires not only that you know the language you are using (C# in this case) but that you be familiar with the classes in the .NET Framework class library. Navigating the huge number of classes in the class library is a daunting task, and it takes a developer many months to get acquainted with the different classes. This appendix summarizes the features of the various versions of the .NET Framework and explains how to use the Object Browser feature in Visual Studio 2008 to browse the available namespaces and classes in the .NET Framework.
Documenting your code is probably the last thing you would do in your typical project cycle. While the importance of writing... more
Documenting your code is probably the last thing you would do in your typical project cycle. While the importance of writing documentation has been stressed umpteen times, developers usually devote the best part of the project cycle to building new features, and then finally do a mediocre job at the end writing the dreaded documentation. Borrowing the popular “clean as you go” phrase found in a lot of kitchens, the best way to churn out top-quality documentation for your project is to document as you go.
In Visual Studio 2008, you can document your code using the XML code documentation feature. This appendix shows you how to generate MSDN-style documentation for your project using Visual Studio 2008 and a third-party documentation generation toolSandcastle.
Purchase Before purchasing this product, please be sure you have met all software and system requirements, and that you understand any limits placed upon its use.
Return Policy Wrox Chapters on Demand are non-returnable and non-refundable.
Watermarking Wrox Chapters on Demand are sold with a small unique watermark at the bottom of each page identifying the purchaser name, email address, and order number.
Reader Software Wrox Chapters on Demand are offered as PDFs, and they can be viewed using the Adobe Reader, ADE, or a compatible PDF reader. If you do not have the Reader installed, it can be downloaded for free at Adobe.com.
Test Download As Wrox Chapters on Demand purchases are non-returnable, it is advisable that you test your system and software configurations with a free sample download before you place an order.
Usage Rights for a Wrox Chapters on Demand File Any Wrox Chapters on Demand product you purchase from this site will come with certain restrictions that allow Wiley to protect the copyrights of its products. After you purchase and download this title, you:
If you have any questions about these restrictions or need any further assistance please refer to Technical Support (www.wiley.com/techsupport) or call (877) 762-2974 (8 a.m. - 5 p.m. EST, Monday - Friday).
Related Books