Generics

There are 3 entries for the tag Generics

Concatenating Delimited Strings With Generic Delegates

UPDATE: In my original example, I created my own delegate for converting objects to strings. Kevin Dente pointed out that there is already a perfectly fine delegate for this purpose, the Converter delegate. I updated my code to use that instead. Thanks Kevin!  Just shows you the size and depth of the Framework libraries. My recent post on concatenating a delimited string sparked quite a bit of commentary.  The inspiration for that post was some code I had to write for a project.  One constraint that I neglected to mention was that I was restricted to .NET 1.1.  Today, I revisit...

Fun Iterating PagedCollections With Generics and Iterators

Oh boy are you in for a roller coaster ride now! Let me start with a question, How do you iterate through a large collection of data without loading the entire collection into memory? The following scenario probably sounds quite familiar to you. You have a lot of data to present to the user. Rather than slapping all of the data onto a page, you display one page of data at a time. One technique for this approach is to define an interface for paged collections like so... /// <summary> /// Base interface for paged collections. /// </summary> public interface IPagedCollection { ///...

Using Generics For Custom Providers To Reduce Code Duplication

Here is a quick little nugget for you custom provider implementers. I recently scanned through this article on MSDN that describes how to implement a custom provider and found some areas for improvement. Reading the section Loading and Initializing Custom Providers I soon encountered a bad smell. No, it was not my upper lip, but rather a code smell. Following the samples when implementing custom providers would lead to a lot of duplicate code. It seemed to me that much of that code is very generic. Did I just say generics? Simone (blog in Italian), a Subtext developer, recently refactored...