This post originated from an RSS feed registered with .NET Buzz
by Peter G Provost.
Original Post: More Fun With CodeDOM
Feed Title: Peter Provost's Geek Noise
Feed URL: /error.aspx?aspxerrorpath=/Rss.aspx
Feed Description: Technology news, development articles, Microsoft .NET, and other stuff...
In WinTechOffTopic,
Chris Sells asked for generalized permutation engine. A number of poeople posted a
bunch of different solutions, one of which was the naive nested for-loop approach.
Works well, but required you to add new for-loops every time you want to add a new
element to the search.
That's when I thought, "You could always use a little dynamic
code generation to do the simple algorithm for the general case."
The performance isn't as good as what Chris actually found,
but it is an interesting way to play with CodeDOM.
using Microsoft.CSharp;
using System;
using System.CodeDom.Compiler;
using System.IO;
using System.Reflection;
using System.Text;
namespace SellsPermutationSpike
{
/// <summary> /// Summary description for Class1. /// </summary> class Class1
{
/// <summary> /// The main entry point for the application. /// </summary>
[STAThread]
staticvoid Main(string[]
args)
{
Util.HiResTimer hrt = new Util.HiResTimer();