■
Source Code
The ExtensionMethods project can be found under the Chapter 13 subdirectory.
Building and Using Extension Libraries
The previous example extended the functionality of various types (such as the System.Int32 type)
for use by the current console application. However, I am sure you could imagine the usefulness of
building a.NET code library that defines numerous extensions that can be referenced by multiple
applications. As luck would have it, doing so is very straightforward.
To illustrate, create a new Class Library project (named MyExtensionsLibrary). Next, rename
your initial C# code file to MyExtensions.cs, and copy the MyExtensions class definition in your new
namespace:
namespace MyExtensionsLibrary
{
Do'stlaringiz bilan baham: |