Noocyte’s Weblog

July 11, 2008

Mini C# Lab

Filed under: Link, Work — Tags: , , — noocyte @ 7:56

Mini C# Lab – Home

A handy tool for simple short C# code running and testing, you can save time on waiting for Visual Studio startup and avoid creating a lot of one-time only project files.

Cool, I very often have to create small samples just to test some ideas or validate some code that I’m using. This should come in handy.

July 2, 2008

Back to Basics – This is not the object you’re looking…wait, oh, it is the object

Filed under: Link — Tags: , — noocyte @ 9:19

Scott Hanselman’s Computer Zen – Back to Basics – This is not the object you’re looking…wait, oh, it is the object

Know your options, but above all, know your intentions and make sure that the code you’re writing correctly expresses your intent.

May 13, 2008

Linq and RegExp

Filed under: Link — Tags: , , — noocyte @ 10:04

I’ve always struggeled with RegExp. Every time I need one I have to use a tool and then carefully create it. Painful. But today I discovered a new project: Readable Regular Expressions. I basically uses Linq syntax to create the regexp for you! Pretty cool!

April 21, 2008

Designing With Lambdas – Part I – Sergio Pereira

Filed under: Link — Tags: , — noocyte @ 15:46

Pretty cool use of Lambdas. Passing functions around is really handy! 🙂

Designing With Lambdas – Part I – Sergio Pereira

March 3, 2008

Charlie Calvert’s Community Blog : Video of Luke Hoban’s In-Depth Look at C# 3.0

Filed under: Link, Work — Tags: , — noocyte @ 9:37

More of a bookmark than anything; I really wanna watch these two presentations asap.

Charlie Calvert’s Community Blog : Video of Luke Hoban’s In-Depth Look at C# 3.0

February 18, 2008

Double Key Dictionary

Filed under: Personal — Tags: , — noocyte @ 23:16

Double Key Dictionary, or; how to make it really simple to use a dictionary with two keys.

In a matter of just weeks I found myself forced to temporarily store values with two unique identifying keys. As an example think about a customer in a web shop who has bought some books. Key number one would be the customer ID and then key number two would be the books ISBN number. The value stored could be the books name. Why you would want to do this I have no idea, but it’s an easy to understand example and it illustrates the problem I had so that everybody can understand it. Its just that I read values from, literally, thousands of Xml logs stored in a database… Anyway!

So what you could do is something like this:

Dictionary<string, Dictionary<string, string>> bookList = new Dictionary<string, Dictionary<string, string>>();
Dictionary<string, string> innerList = new…
innerList.Add(“11-22-33”, “Lord of the Rings”);
bookList.Add(“James”, innerList);

That works and would perhaps be good enough. But what happens if you want to compare two lists of books? And it’s not unthinkable that you might end up trying to add the same book, for the same person, more than once. How do you handle that? Lots of manual checks? More on my solution later on…

Even if I could make the problems outlined above go away (as in create little helper methods to sort them out) I just didn’t like the syntax. It felt just so wrong. What I wanted would be something like this:

DoubleKeyDictionary<string, string, string> bookListEx = new DoubleKeyDictionary<string, string, string>();
bookListEx.Add(“James”, “11-22-33”, “Lord of …”);

(Abbreviated for clarity)

So I implemented the DoubleKeyDictionary, as a two key generic dictionary. My implementation also includes IEnumerable<T>, IEquatable<T> and I added an index. All this enables me to use this syntax:

DoubleKeyDictionary<string, string, string> bookListEx = new DoubleKeyDictionary<string, string, string>();
bookListEx.Add(“James”, “11-22-33”, “Lord of the Rings”);

DoubleKeyDictionary<string, string, string> bookList = new DoubleKeyDictionary<string, string, string>();
bookList.Add(“James”, “10-20-30”, “Narnia”);

if (bookList.Equals(bookListEx))
    Console.WriteLine(“They are equal”);

foreach (DoubleKeyPairValue<string, string, string> books in bookListEx)
    Console.WriteLine(books.ToString());

Sorry about the bad formatting. Please download the actual code file [new window]. Please feel free to use the code if you like it. If not; tell me why!

February 7, 2008

Joshua Flanagan – The power of yield (return)

Filed under: Link, Work — Tags: , — noocyte @ 11:39

yield is pretty cool and this was a simple and good example of how to use it and why you would want to. 

Link to Joshua Flanagan – The power of yield (return)

October 29, 2007

C# 4.0 Feature Request: "??=" the Lazy load operator… – The Bolla Blog

Filed under: Link — Tags: , — noocyte @ 15:01

Not bad… I can see lots of uses for such an operator. However I do fear that we’re soon approaching “feature bloat” in C#… I worry alot about that actually… 

Link to C# 4.0 Feature Request: “??=” the Lazy load operator… – The Bolla Blog

October 16, 2007

J.D. Meier’s Blog : How To: Create a “Hello World” WCF Service Using Visual Studio

Filed under: Link — Tags: , , — noocyte @ 7:06

 

Link to J.D. Meier’s Blog : How To: Create a “Hello World” WCF Service Using Visual Studio

PaulStovell.NET » Introducing SyncLINQ

Filed under: Link — Tags: , , — noocyte @ 6:57

 

Link to PaulStovell.NET » Introducing SyncLINQ

Blog at WordPress.com.