ForEach, a simple but very useful extension method

August 21, 2008 01:24 by admin

Glenn Block has an implementation of ForEach for IEnumerable:

  1: public static class IEnumerableUtils {
  2:   public static void ForEach<T>(this IEnumerable<T> collection, Action<T> action) {
  3:     foreach(T item in collection) {
  4:     action(item);
  5:   }
  6: }

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

List of LINQ Prividers

July 14, 2008 00:46 by admin

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

A Smarter (or Pure Evil) ToString with Extension Methods

May 1, 2008 12:18 by admin

Scott Hanselman is at it again with a smarter and possibly evil ToString extension method.  Here is his example usage:

public void MakeSimplePersonFormattedStringWithDoubleFormatted()
{
    Person p = new Person();
    string foo = p.ToString("{Money:C} {LastName}, {ScottName} {BirthDate}");
    Assert.AreEqual("$3.43 Hanselman, {ScottName} 1/22/1974 12:00:00 AM", foo);
}

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

How do Extension Methods work and why was a new CLR not required?

April 7, 2008 01:19 by Admin

Scott Hanselman goes into detail about how extension methods work.  Want the short answer?  It's all taken care of at compile time.


Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Pattern Matching in C# - Part 0

April 7, 2008 01:17 by Admin

Bart De Smet just posted part 0 in his new series about pattern matching in C#.


Currently rated 5.0 by 4 people

  • Currently 5/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Multiple Item support for same property in where clause : LinqExtender

April 7, 2008 01:11 by Admin

Mehfuz's adds the ability to use the same property multiple times in the where clause of a query to LinqExtender.  That's a little confusing, so here is the example that he gave:

var query = from book in _context.Books
            where book.PublishedDate > someDate 
            and book.PublishedDate < someDate
            select book;
 
 

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Parallel Extensions, LINQ and PLINQ

March 16, 2008 03:26 by admin

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

LINQ and More

March 16, 2008 03:19 by admin

Scott Hanselman's Weekly Source Code series edition 19 covers LINQ and More.


Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Cool Entity Framework Sample

March 16, 2008 03:16 by admin

The ADO.NET team blog has a post about a Drawing Editor sample application that is based on the Entity Framework.


Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Turn Anonymous Types into IDictionary of Values

March 11, 2008 10:03 by Admin

Very cool!  Roy Osherove shows how to convert anonymous types into IDictionary.


Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5