James Michael Hare

...hare-brained ideas from the realm of software development...
posts - 166 , comments - 1431 , trackbacks - 0

My Links


Welcome to my blog! I'm a Sr. Software Development Engineer in the Seattle area, who has been performing C++/C#/Java development for over 20 years, but have definitely learned that there is always more to learn!

All thoughts and opinions expressed in my blog and my comments are my own and do not represent the thoughts of my employer.

Blogs I Read

Follow BlkRabbitCoder on Twitter

Tag Cloud




Little Wonders

Little Wonders


January 2011 Entries

C#/.NET Little Pitfalls: The Dangers of Casting Boxed Values
Starting a new series to parallel the Little Wonders series. In this series, I will examine some of the small pitfalls that can occasionally trip up developers. Introduction: Of Casts and Conversions What happens when we try to assign from an int and a double and vice-versa? 1: double pi = 3.14; 2: int theAnswer = 42; 3: 4: // implicit widening conversion, compiles! 5: double doubleAnswer = theAnswer; 6: 7: // implicit narrowing conversion, compiler error! 8: int intPi = pi; As you can see from the ......

Posted On Thursday, January 27, 2011 7:30 PM | Comments (1) | Filed Under [ My Blog C# Software Little Pitfalls ]

C#/.NET Little Wonders: Comparer<T>.Default
I’ve been working with a wonderful team on a major release where I work, which has had the side-effect of occupying most of my spare time preparing, testing, and monitoring. However, I do have this Little Wonder tidbit to offer today. Introduction The IComparable<T> interface is great for implementing a natural order for a data type. It’s a very simple interface with a single method Compare() that compares two items of type T and returns an integer result. So what do we expect for the integer ......

Posted On Thursday, January 20, 2011 9:08 PM | Comments (5) | Filed Under [ My Blog C# Software Little Wonders ]

C#/.NET Little Wonders: Constraining Generics with Where Clause
Back when I was primarily a C++ developer, I loved C++ templates. The power of writing very reusable generic classes brought the art of programming to a brand new level. Unfortunately, when .NET 1.0 came about, they didn’t have a template equivalent. With .NET 2.0 however, we finally got generics, which once again let us spread our wings and program more generically in the world of .NET However, C# generics behave in some ways very differently from their C++ template cousins. There is a handy clause, ......

Posted On Thursday, January 13, 2011 6:29 PM | Comments (0) | Filed Under [ My Blog C# Software .NET Little Wonders ]

C#/.NET Fundamentals: Finding an Item’s Index in IEnumerable<T>
Sorry for the long blogging hiatus. First it was, of course, the holidays hustle and bustle, then my brother and his wife gave birth to their son, so I’ve been away from my blogging for two weeks. Background: Finding an item’s index in List<T> is easy… Many times in our day to day programming activities, we want to find the index of an item in a collection. Now, if we have a List<T> and we’re looking for the item itself this is trivial: 1: // assume have a list of ints: 2: var list = ......

Posted On Thursday, January 6, 2011 7:29 PM | Comments (4) | Filed Under [ My Blog C# Software .NET Fundamentals ]

Powered by: