CSharpFeeds - All your C# feeds in one place.

Thursday, February 28, 2008

C# Multi-Valued Enums - Extension Method Style

by Paul Stovell via Paul Stovell on 2/28/2008 12:07:41 PM

Omar blogged a method to extract the selected values in an enumeration: http://blog.omarbesiso.net/index.php/2008/02/13/c-multi-valued-enumerators-flags/ Suppose you had an flags enumeration called Option. You could use his method to write the following code: Options options = Options.ReadOnly | Options.Archive; Console.WriteLine("You selected:"); foreach (Options option in EnumHelper.GetSelectedEnumValues<Options>(options)) { Console.WriteLine(option); } While a generic ...

[ read more ]

Implementing deferred execution, and a potential trap to avoid

by skeet via Jon Skeet's Coding Blog : C# on 2/28/2008 12:32:18 AM

When talking about LINQ recently, I doodled an implementation of OrderBy on a whiteboard. Now, I know the real OrderBy method has to support ThenBy which makes life slightly tougher, but let's suppose for a moment that it didn't. Let's further suppose that we don't mind O(n2) efficiency, but we do want to abide by the restriction that the sort should be stable. Here's one implementation: public static IEnumerable<TSource> OrderBy<TSource,TKey>  &nb ...

[ read more ]

Subscribe

New Feed

Product Spotlight

Recently Updated Sources

Legal Note

The content of the postings is owned by the respective author. CSharpFeeds is not responsible for the contents of the postings. This site is automatically generated and cannot be reviewed for abusive content. If you find abusive content on CSharpFeeds, please contact us. Designated trademarks and brands are the property of their respective owners. All rights reserved.

Advertise with us