Omer van Kloeten's .NET Zen

Programming is life, the rest is mere details

News

Omer van Kloeten's Facebook profile

Get Firefox

.NET Resources

Articles :: CodeDom

Articles :: nGineer

Culture

Projects

Browse by Tags

All Tags » C# (RSS)
Extension Methods Roundup: Remove, Aggregate, At, AsIndexed and Friends
Hey hey hey! It's time for another Extension Methods Roundup! Here are some of the extension methods I've written since the last one: Dictionary's Missing Remove Methods public static void Remove<TKey, TValue>( this IDictionary <TKey, TValue>...
Breadth Recursion - a yield Solution to Post's Correspondence Problem
Post's Correspondence Problem (the other PCP) is a computer science problem, in which you have (and I simplify matters) a set of tiles, each having any number of letters on them from a preset group. For instance, you may have the tiles: The idea is to...
LINQ Performance Pitfall - Deferred Execution
When using LINQ, queries may bloat up to dozens of lines. My personal style is to take these queries and break them apart to smaller units of logic. To each unit of logic, I append a call to ToArray . @yosit asked me why I did it and I answered I was...
Extension Methods Roundup: IndicesWhere, TakeEvery, Distinct
As I do from time to time, here is a batch of three Extension Methods I've written recently: IndicesWhere /// <summary> /// Gets the indices where the predicate is true. /// </summary> public static IEnumerable < int > IndicesWhere<T>...
A Limitation of Lambda Expressions and Overloaded Extension Methods
Tamir hates lambdas. He was having a problem with one of his lambda expressions and twittered about it. Around that time I opened my twitter account (yes, Yosi finally convinced me) and offered my help. He wanted to have a single extension method that...
Linq: The Missing ToDictionary Extension Method Overload
Enumerating over a Dictionary<TKey, TValue> you will get structs of type KeyValuePair<TKey, TValue> . Whenever you use the ToDictionary extension method, you are forced to specify how to get the key and value for each item, even if it's an...
Linq: SequenceSuperset
Here's another Linq method I wanted to share. This one takes two enumerations, enumeration and subset and checks to see whether subset exists in enumeration in its original order. I used the naming convention set by SequenceEqual . Examples: enumeration...
Linq: ContainsAtLeast and AggregationOrDefault
I've created a couple of useful extension methods that I like to use with Linq, so here they are: ContainsAtLeast I've noticed that there's no way to find out whether a collection has at least X items. The following takes the collection, tries to take...
C# Feature Request: Type Member Level Generic Constraints
The Basic Need Take the following code: public abstract class Base { protected Base( int something) { // ... } } public class Derived : Base { public Derived( int something) : base (something) { // ... } } public class Derived2 : Base { public Derived2...
Posted: Apr 02 2008, 11:57 AM by Omer van Kloeten | with 17 comment(s)
Filed under: ,
Releasing My Code Snippet Repository
Whenever I teach classes or do demos, I get asked about the C# code snippets I use in Visual Studio, so I decided to release them, if anyone would like to use them. I've created a project on CodePlex and I'll try to update it whenever I write a new one...
More Posts Next page »