c-sharp
There are 5 entries for the tag c-sharp
Thursday, October 28, 2010 10:44 PM | Comments

Portable Library Projects At MIX 10 Microsoft announced a rather modest code-sharing technique to allow Silverlight and .NET apps to share a small subset of System.* libraries. Well today at PDC Shawn Burke had a 60-minute session called “3-screen coding – Sharing code between Windows Phone, Silverlight, and .NET.” He unveiled a new Class Library project type called a “Portable Library” which can be directly referenced by any type of project. The obvious goal here is to share your core business logic between your various client-side applications. Thankfully Visual Studio will even trim IntelliSense within a Portable Library project to only APIs which have been specifically defined as portable between all application types. Release date for Portable Library projects is H1 2011 PDC Video: 3-Screen Coding   Async Programming Improvements Probably the most popular announcement today was “The Future of C# and VB” talk,...

Wednesday, August 18, 2010 11:58 AM | Comments

A year ago I had written briefly about my love-affair with the yield keyword. Today a question was posed to me and the follow-up discussion was interesting enough to me to warrant a quick post. If you're returning an IEnumberable<T> from a method that reads from a DataReader, is it bad to use yield? My concern is calling a long-running method while looping over the items returned from the method – won’t this keep the SQL connection open longer? Also what if an exception happens while looping, will my reader still get closed? His proposed API was similar to the following very common (and outdated, IMHO) pattern – which is turning a DataReader into data access or business objects. The Proposed API public List<string> GetItemsList() { using (var reader = new FakeDataReader()) { ...

Wednesday, February 17, 2010 10:31 AM | Comments

I saw the following question asked earlier today -- the only context given was the code itself. Can anyone tell me what’s wrong with this Dim min As Integer = Integer.Parse(leavingTimeTextBox.Text.Substring(leavingTimeTextBox.Text.IndexOf(":") + 1, leavingTimeTextBox.Text.Length) -1 )? it shows me an exception index out of range exception: length and index must be within the range of the string, parameter name: length  so its five characters and on debug time : index is 2 so I'm starting from index 3 to length which is 5 -1 "4" It was clear that he looking to parse some sort of pre-defined time format, but just to be sure I confirmed it with him. While I could have helped this person resolve the question he asked about (the IndexOutOfRangeException), instead I took a step back to focus on what he really wanted to achieve. His immediate  problem was that he was too focused on the...

Tuesday, September 22, 2009 12:01 AM | Comments

This post was spawned as I was reviewing the latest Oxite source code on CodePlex. I’ve been reading any source code I could get my hands on lately looking for inspiration to cure my “winter coding boredom.” While it isn’t winter yet, it is fast approaching, which means less outdoors time and more computer time. I try to blog more, update my open source projects with a new release, and with any luck begin a new project worth getting passionate about. Today I'm going to hit the ground running with a short tip, again, on the yield keyword. The following code is an excerpt from the Oxite Blog class. Blog as it turns out, is a Cacheable Entity (ICacheEntity) where the designer of the interface determined that cached entities can specify any dependencies they may have. Clearly, the developer of the ICacheEntity interface understood iterators and realized that the consumer of...

Monday, September 7, 2009 9:55 PM | Comments

This was one of the first extension methods I wrote when C# 3.0 arrived, since I just stumbled across it on an older project I figured I might as well post it, if for nothing else but future reference. One downside to be aware of if you choose to use this method, is that it will not project the results on a IQueryable provider like LINQ to SQL, so please be aware the conversion will be done on the client side. The Code public static class DelimitedStringExtensions { public static string DefaultDelimiter = ", "; /// <summary> /// Convert a sequence of items to a delimited string. By default, ToString() will be called on each item in the sequence to formulate the result. The default delimiter of ', ' will be used /// </summary> public static string...