Archive for the ‘C#’ Category

.NET Streams cheatsheet

Thursday, November 19th, 2009

A summary of streams in .NET. TextReader [abstract] -----> StringReader -----> StreamReader TextWriter [abstract] -----> StringWriter (uses underlying StringBuilder) -----> StreamWriter

ObjectDataSource : how to set insert / update parameters programmatically

Tuesday, November 10th, 2009

Having begun programming with ASP.NET from its inception where you wrote your own solutions to common problems, I've found the introduction of ObjectDataSource objects and similar functionality a blessing and a curse. Although they can save a bit of coding I always find my self wasting lots of time trying ...

How to get the parts of a URL in ASP.NET

Tuesday, June 30th, 2009

Every time I need to parse a URL or to extract parts of a URL in ASP.NET C# I can never remember what I did last time and need to refer to the documentation. So, in order to quickly answer the question "How can I get the elements of a ...

LINQ TO SQL : WHERE X IN ()

Monday, June 22nd, 2009

I recently needed to do a WHERE X IN () style query using LINQ to SQL. Here's the solution I used:

Extension methods (C#)

Monday, June 8th, 2009

Extension methods enable you to "add" methods to existing types without creating a new derived type, recompiling, or otherwise modifying the original type. Extension methods are a special kind of static method, but they are called as if they were instance methods on the extended type. For client code written ...

yield return (C#)

Monday, June 8th, 2009

The yield keyword signals to the compiler that the method in which it appears is an iterator block. The compiler generates a class to implement the behavior that is expressed in the iterator block. In the iterator block, the yield keyword is used together with the return keyword to provide ...