When is a char not a char? When it’s an int.

Just discovered a curious quirk in C#’s handling of the char type. Most of the time you can just think of it as being a character type, like a single character within a string, but actually it isn’t. It has an implicit coversion to int, but not to string, so

Console.WriteLine('A' + 'B');

would produce 131. Continue reading “When is a char not a char? When it’s an int.”

FtpWebRequest bug

I’ve just run into what appears to be a bug in .net’s FtpWebRequest class. I wrote some rather inefficient code that requested the same directory listing from the server several times, and found that it hung the second or third time it made the request. After some googling, I found an explanation. It seems that it caches some of the objects it creates and retrieves them from a pool, which is fine, but if it finds that the request is identical to the existing one it doesn’t reopen the response socket, so when you try to get the response stream it hangs. It’s a simple fix in my program, just save the result of the list request, but it would make it very difficult to write something that works by polling the contents of an ftp folder.

Sorting a grid bound to a BindingList

I’ve just been trying to implement move up/down buttons on the rows of a C1Flexgrid bound to a BindingList. I can’t believe how hard going it was. You would think that telling the grid to sort itself on the column containing the sort order would do it, but it doesn’t. Despite the implications in the documentation, if you read it very carefully you realise that it always uses the sort order of the underlying BindingList, regardless of what else it has been told to do. The only way to make it resort its rows is to clear out the binding list and rebuild it in the desired order.

I finally found an explanation of how to do it on StackOverflow.

Radio Player

When I first installed Windows 7 I found a nice little BBC Radio Player gadget, and I’ve been using it to listen to the BBC while I’m working ever since. However, the BBC recently renamed BBC 7 as Radio 4 Extra and eventually stopped the old url, so the gadget can’t find it any more.

This spurred me to write a radio player myself. Continue reading “Radio Player”

Cuemaster

My main client went into Administration last week, leaving me with very little work to do until I can find another contract, which is proving a little difficult.

This has, however, given me the chance to get on with writing Cuemaster. This is a Windows program that Trevor Learoyd recently bought the rights to. After looking over the code I decided it needed a complete rewrite, which I have almost completed. Continue reading “Cuemaster”

textarea sizes

I’ve just run into a problem with laying a page containing a textarea.

I set it up using a Firefox window with a 1024*768 client area on Windows XP, but when I looked at it on Linux (Centos) the rest of the page ran off the bottom, even though everything should have been in the same position. Turns out that the Windows Mozilla is making the box 5 rows deep, as requested, but the Linux version is allocating space for scrollbars that aren’t needed.

Both are running Firefox 2.0.0.14, so there must be some difference in the underlying rendering libraries.