Tips

S3 – Use using block to get the stream

When you’re using the Amazon S3 client, have you come across the occasional exception that says something like one of these exception messages: “The request was aborted: The connection was closed unexpectedly” “Unable to read data from the transport connection: A blocking operation was interrupted by a call to WSACancelBlockingCall” “Unable to read data from …

S3 – Use using block to get the stream Read More »

.Net Tips – Use LINQ to create pairs of adjacent elements from a collection

Suppose you have an array of numbers, say, [1, 3, 5, 7, 9, …], and you want to pair each element up with its neighbour in the array, e.g. [[1, 3], [3, 5], [5, 7], [7, 9], …]. Sure, you can iterate through the indices of the elements and recursively grab the element at an …

.Net Tips – Use LINQ to create pairs of adjacent elements from a collection Read More »

.Net Tips – Make sure the runtime types match when combining delegates

In C#, it’s possible to combine two delegates, A and B to create a new multicast delegate, C:   When the multicast delegate is executed, the combined delegates are executed in order as you can see from the example above. But before you can start mix and matching your delegates like a kid in a …

.Net Tips – Make sure the runtime types match when combining delegates Read More »

Things I didn’t know about expando objects

I found out two interesting things about the ExpandoObject class introduced in C# 4 this bank holiday weekend: 1. you can specify custom events on them 2. it implements the INotifyPropertyChanged interface Here are some quick demos to show you how to use these features: Custom Events To add a custom event is the same …

Things I didn’t know about expando objects Read More »

.Net Tips – Working with anonymous types

Anonymous types are useful, especially in LINQ queries where you often want to iterate through an array of items and project them into some arbitrarily shaped objects that are little more than simple data containers, using anonymous types save you the hassle of having to first declare those types which you will simply throw away …

.Net Tips – Working with anonymous types Read More »

By continuing to use the site, you agree to the use of cookies. more information

The cookie settings on this website are set to "allow cookies" to give you the best browsing experience possible. If you continue to use this website without changing your cookie settings or you click "Accept" below then you are consenting to this.

Close