September 2007 - Posts

GO CATS !!
GO CATS !!
GO CATS
with 1 comment(s)
Filed under:

Here's before and after pictures of pink ice protea:

 

with no comments
Filed under:

late this afternoon I noticed an echidna walking around near one of the wind breaks, so I snapped a few photos. Usually they burrow in when people approach, this  one did but then decided to stick his/her nose out to say hi :)

 

 

More photos of him/her on my picassa gallery:
http://picasaweb.google.com.au/Bill.McCarthy.MVP/TheFarm

 

.

with no comments
Filed under:

Thanks to Julie's post, I decided to dig deeper into the depths of VB than any sane man should go. While playing with nullable dates in the query, I was wondering why I could get the number of orders with a null ShipDate.

I tried:

Dim query = From order In db.SalesOrderHeaders _
            Where Not order.ShipDate = Nothing

 

that returned 0.

Then I thought what about Is ?

Dim query = From order In db.SalesOrderHeaders _
            Where Not order.ShipDate Is Nothing

That returns the correct number, which in my modified data is 2.

Now the thing to note here is that ShipDate is a Nullable(of Date), and as such is a value type.  If you try to use the Is operator with a nullable type in VB 2005 you'll get an error telling you can't use Is with value types.  In fact you'll get the same error in VB9 (2008) unless the operand is Nothing, e.g:

Dim dt1 As Date?

Dim dt2 As Date?

Dim result As Boolean = dt1 Is Nothing ' legal

Dim result2 As Boolean = dt1 Is dt2 ' ILLEGAL

So, the new role for Is is when comparing a nullable type to the Nothing constant.

 And likewise you can use IsNot with Nothing on nullable types too,

with 2 comment(s)
Filed under: , , ,

As I uploaded a couple more photos to my flickr account, I got a warning that I had exceeded the 200 photo limit.  After looking for alternatives, such as My Spaces etc, I settled on Google's Picasa.  The software is easy to use (although it lacks tagging it does albums well.  So my photo gallery is now at

http://picasaweb.google.com/Bill.McCarthy.MVP

 

with no comments
Filed under:

C# has some interesting rules for operators on nullable types. Given:

int? x ;
int? y ;

Laws of transitivity tells us that if x is equal to y, (x == y), then x<= y would be true too. Well not in C#.

With this function:

static void test(int? arg1, int? arg2)
{
    Console.WriteLine("arg1 == arg2 returns {0}", (arg1 == arg2));
    Console.WriteLine("arg1 <= arg2 returns {0}", (arg1 <= arg2));
}

 

The output in some cases will be:

arg1 == arg2 returns True
arg1 <= arg2 returns False

 

Sad to see C# break basic laws of logic and mathematics like this. :(  

Thankfully VB doesn't make this mistake :)

with 8 comment(s)
Filed under: , , ,

Spring is here, the weather is lovely and some of the fruit trees are in full blossom  :)

 

 

with no comments
Filed under:

It's Spring here, and I got me a new automatic twin head lawn mower:

with 2 comment(s)
Filed under:

Was just reading Julie Lerman's blog and noticed the issue she had wouldn't have happened if Option Strict was on.  This really highlights the problem of having implicit conversions occur at runtime.
with no comments
Filed under: , , ,