Posts tagged Design
Design Guidelines for LINQ
Mar 13th
Have you wondered if and when you should use the new LINQ features in .Net 3.5?
Like, where should I put a new extension method? Should I use Func<T> or a custom delegate? How do I best implement a mix-in (extension methods on an interface)?
Well, Mircea Trofin has just published a new draft of some LINQ design guidelines. You might just find your answers there.
ASP.Net MVC Corollary – What to do?
Jan 28th
Using LinqPad to Create a Time-Selector Drop-Down List
Jan 18th
I am really getting into LINQ now! I think it’s fantastic. I recently wanted to develop a quick drop-down list in ASP.Net which allows a user to select a time of day from a list. The times are 15 minutes apart, so the list would look like this:
…
08:00
08:15
08:30
08:45
09:00
…
… and so on.
Before LINQ, I would have done this with a for loop, like this:
List<string> times = new List<string>(); for (int hour = 0; hour < 24; hour++) for (int minute = 0; minute < 60; minute++) if (minute % 15 == 0) times.Add(string.Format( "{0:00}:{1:00}", hour, minute));
That’s not difficult, although it’s not so easy to understand. I would have to write a small console app or test to make sure I had done it correct though.
I thought this might be a good opportunity to use LinqPad. It’s a great tool. You can use it to test a LINQ statement in a live window, so I thought I’d give it a go.
First I needed a LINQ statement to test.