Category Archives: C#

FastSharp 2.0

I just released a new version of my FastSharp program. Download it  or  View the source code This release contains some notable enhancements: Support for multiple languages C# Visual Basic F# Pers…

Continue reading
Posted in C#, F#, FastSharp, Visual Studio Gallery | Leave a comment

DiffPlex 1.1 Released

I released a small update to DiffPlex that helps improve performance for both the release and debug builds.  I now also package the release build in the download zip file instead of the debug.  The release build shows a significant performanc…

Continue reading
Posted in C#, DiffPlex, Programming | Leave a comment

Useful Moq Extension Method

I have been working with ASP .NET MVC and I use the Moq mocking library to help test the code I write.   Often in ASP MVC anonymous objects are passed around as function arguments.  This is especially common in calls to RouteUrl.  S…

Continue reading
Posted in ASP .NET MVC, C#, Moq | Leave a comment

Converting RTF to HTML

Have you ever had the desire to convert some RTF text into HTML? Probably not. But if you do, then you are in luck! I recently had the need to do this conversion and after some searching found out a way to do it by enhancing a sample distributed in the…

Continue reading
Posted in C#, HTML, RTF, WPF, XAML | Leave a comment

I finally got fed up with Enum.Parse

I don’t know why I didn’t do this long ago, but I am done writing this: var val = (SomeEnum)Enum.Parse(typeof(SomeEnum),”someString”);

I have typed this too many times and it annoys me. 

I wrote a small extension method on the st…

Continue reading
Posted in C# | Leave a comment

My xUnit.net Visual Studio Code Snippets

The xUnit .Net codeplex page lists one useful Visual Studio code snippet for creating a Fact.  As you can tell I am fairly fond of code snippets so I created a few more which I use when writing xUnit.net facts. These are one line snippets that I f…

Continue reading
Posted in C#, Snippets, Visual Studio | Comments Off

Inline Regular Expression Options

I was using attributes from the System.ComponentModel.DataAnnotations   namespace for model validation.  This namespace includes a few very useful validation attributes such as Required Attribute – Validates the field has a va…

Continue reading
Posted in C#, Regular Expression | Comments Off

Model Binder

When working with a multi-tier application I often find myself converting from one of the tiers object models to my own similar (but often different) model.  I often write code that would set one by one each property from a … Continue reading

Posted in C# | Leave a comment

What annoys me when writing generic functions in Visual Studio…

When writing a generic function I start from left to right (the same way I write most things except when I took Yiddish in college).  For example, Lets say I am writing a simple generic method which return the first … Continue reading

Posted in C# | Leave a comment

Worst Case Scenario for QuickSort

Take a look at the following code: 1: var sw = new Stopwatch(); 2: sw.Start(); 3: Enumerable.Range(0, 3).SelectMany((i) => Enumerable.Range(0, 50000)).OrderBy(i => i).ToList(); 4: Console.WriteLine(sw.ElapsedMilliseconds); 5:  6: sw.Reset(); 7: sw.Start(); 8: Enumerable.Range(0, 2).SelectMany((i) => Enumerable.Range(0, 50000)).OrderBy(i => i).ToList(); 9: Console.WriteLine(sw.ElapsedMilliseconds); … Continue reading

Posted in Algorithms, C# | Leave a comment