6 posts with tag C#

The impact of SqlDataReader.GetOrdinal on performance

I recently had a discussion about the impact of SqlDataReader.GetOrdinal on execution of a SqlClient.SqlCommand. I then decided to run some code to measure the difference, because I think that's the o…

· 3 minutes reading time

TransactionScope & SqlConnection not rolling back? Here's why...

A while back we ran into an issue with one of our projects where we executed a erroneous query (missing DELETE statement), and then left the database in an inconsistent state. Which is weird, consider…

· 2 minutes reading time

About a dictionary, removing and adding items, and their order.

I had a weird problem today using a Dictionary. The process involved removing and adding data, and then printing the data. I assumed that it was ordered. I was wrong! Let me show you: var dictionary =…

· 2 minutes reading time

Default values and overloads are not the same!

Consider the following class of the Awesome(r) library, using default parameters. public class Foo { public void DoCall(int timeout = 10) { /* awesome implementation goes here */ }…

· 1 minute reading time

C# 5.0 spec is available online now!

A few posts ago I blogged about C# 5.0 and foreach. I mentioned a part of the docs, but those weren't online yet! They are now! http://www.microsoft.com/en-us/download/confirmation.aspx?id=7029 Enjoy …

· 1 minute reading time

When using an enum in PowerShell, use the member's name, not the member's value

Consider the following enum in C#: enum State { Started, Stopped, Unknown } Note that I have not added an explicit value for the enum members. They will be generated by the compiler. As st…

· 2 minutes reading time