Type inference, don’t get bitten by var

I've been playing with some of the new features in C#, one of which being the var keyword.  Which is not dynamic typing, it is just type inference.  Meaning that the compiler will be assigning the type based on the value that you initialise the variable with when declaring it.  And you have to initialise it with an actual value when using var.

After playing a bit, I discovered this little problem, which is probably just an incorrect assumption from my side, but I'm sure I'm not the only one that will make this assumption.  If you look at this code sample.

Continue reading Type inference, don’t get bitten by var

If only we could all strive towards code perfection

I’ve found two views out there about writing good excellent code, that I absolutely have to agree with.

One is on CodingHorror, by Jeff Atwood, saying that writing code is just like writing, ultimately your co-software developers have to understand what your meaning was, and if they cannot figure it out, you’re doing it wrong.

In Jeff’s post there is reference to this post by Ned Batchelder, which basically gives you THE rule about removing dead code, which I have to admit, I’ve been breaking a big percentage of the time.  From now on, in my quest for personal improvement, I will definitely be following both these guidelines.

What are your thoughts on writing good code?

SSIS – Accessing variables from script components

 In SSIS there are are two different types of script components.  The Control Flow script, and the Data Flow script.  These 2 use different ways of accessing package variables, which was a bit confusing the first time I used teh Data Flow script component.

In the Control Flow script component you access package variables in a similar way to how DTS used to do it.

Dts.Variables("User::FromDate").Value.ToString

 However, trying this in the DataFlow script component only cause some compilation errors and nothing more.

After doing some searching, I eventually found the simple solution that was staring me in the face all along, I just never tried it.

Me.ReadOnlyVariables("User::FileName").Value.ToString()

In both cases you still have to tell the component which variables you're passing in on the property page.