Binary tree (count nodes) interview question

Given a LEFT and a RIGHT property that returns the underlying LEFT tree and the underlying RIGHT tree respectively, find the total count of the nodes in the tree. class BinaryTree<T> { private BinaryTree<T> left; private BinaryTree<T> right; public int

Read More Binary tree (count nodes) interview question

LINQ–search for items in a list that are present in another list

Suppose you have a list of strings – a nursery rhyme may be a good example.  And you need to find ALL the words that match from another list of words. Using LINQ to search a list for items in

Read More LINQ–search for items in a list that are present in another list

Filesystem notes from the real world–C#

These are just some quick tidbits about file processing in C#.  Reading in files, reading in LARGE files, Reading and Processing Large Files.   Reading a file (use a StreamReader) if (File.Exists(path)) { using (StreamReader sr = new StreamReader(path)) {

Read More Filesystem notes from the real world–C#

Async and Await, an easy way to keep your user interface responsive

Introduction Normally, when you invoke a method, it is invoked synchronously on your calling thread. Since you made no provision to ‘unblock’ the main thread, the method essentially ‘blocks’ the thread – which means that nothing else can happen until

Read More Async and Await, an easy way to keep your user interface responsive

The Publish Subscribe Pattern in C# and some gotchas

This post does three things: Provides a complete implementation of the publish subscribe pattern in C#. Highlights 4 potential issues that are inherent to ANY publish subscribe implementation – including the one provided here. Provides original, tested workarounds for each

Read More The Publish Subscribe Pattern in C# and some gotchas

C#, .NET Exception Handling Best Practices

The Problem Statement You have just started working on an existing codebase – an n-Tier project – and noticed that the Exception Handling framework wasn’t as well defined as you would expect. Some specific things that bother you include: Lack

Read More C#, .NET Exception Handling Best Practices

New interfaces for implementing Publish-Subscribe in .NET

You know you are a techie at heart if you find yourself getting excited at the introduction of a couple of new interfaces. .NET 4.0 introduces IObservable (Publisher) and IObserver (Subscriber). These interfaces were long overdue – for a couple

Read More New interfaces for implementing Publish-Subscribe in .NET