Geeks With Blogs
New Things I Learned February 2008 Entries
Lambda Expression type inference doesn't quite work on actual methods
One of the nice things with lambda expression is type inference - it is actually pretty neat. A neat example that is as follows: private void Test() { string original = "Muljadi"; string upper = Demo(original, s => s.ToUpper()); int length = Demo(original, s => s.Length); } private static TResult Demo<T, TResult>(T value, Func<T, TResult> func) { return func(value); } In the example above, the first call to the Demo method has first parameter being a string - which then is immediately ......

Posted On Wednesday, February 13, 2008 6:47 PM

Expensive Home theatre...
One of my hobby / passion is home theaters, and even though $6 million is overkill, I thought I would brought it up as a good read . Kipnis Studio Standard, 4096x2160 video, 18 ft screen, 8 speakers with 8 subs... The Sony Quad HD projector is one of interest to me - it costs $100K (if this post is to be believed) with NO lens (another $19K option give or take a couple of grand given what kind of lens you want), but I would like to see how an 8 megapixel image would look like on a big screen. Of ......

Posted On Monday, February 11, 2008 9:45 AM

My foray into Lambda Expressions
I was aware of lambda expressions because I was reading about them in the C# 3.0 white paper specification, along with other new language features like extension methods, anonymous types, basis for LINQ, etc. I thought it was cool enough, it makes passing anonymous delegates much better in terms of code writing/reading. However, actually using them takes a bit of getting used to. As such, I'd like to give a short example as to how I visualize writing lambda expressions. Consider the following class ......

Posted On Monday, February 11, 2008 9:16 AM

New delegates in .NET Framework 3.5
In the way distant past, I ended up creating a new delegate for just about each function I need represented as a delegate. And as I experienced an explosion of delegates and needing to come up with the names for it, I ended up creating 2 sets of delegates as follows: public delegate void VoidFunction(); public delegate void VoidFunction<T>(T argument1); public delegate void VoidFunction<T, U>(T argument1, U argument2); public delegate R Function<R>(); public delegate R Function<R, ......

Posted On Friday, February 8, 2008 12:19 PM

Disposing CollectionView (Detaching your data and the CollectionView)
One of my prior post talks about how CollectionView (and anything deriving from it like ListCollectionView) doesn't get garbage collected after use - even worse it continues to hang onto the data it was bound to, which may cause performance issues. After fiddling through this, I found 3 ways to disconnect them, which I'll detail below. - Derive classes from CollectionView that can dispose itself. The subscriber to the CollectionChanged event is a protected function named 'OnCollectionChanged' - so ......

Posted On Thursday, February 7, 2008 6:08 PM

Advantage in creating a base non-generic class
In the project I'm working in, we use generics a lot - I mean a LOT! Most of the classes we create are also generic types - it provides some niceties that way. As the classes grew, eventually I got to a point where I want to put in a static function that doesn't deal with the generic type, something like below: public abstract class Container<T> { private T _content; public T Content { get { return _content; } set { _content = value; } } public static void SomeStaticFunctionNotInvolv... ......

Posted On Tuesday, February 5, 2008 6:38 PM

Copyright © Muljadi Budiman | Powered by: GeeksWithBlogs.net