porges

Tag: Programming

Objects can be collected while their instance methods are still executing

In Peter Ritchie’s post Dispose Pattern and “Set large fields to null”, he states the following (my highlighting): At face value, setting a field to null means that the referenced object is now unrooted from the class that owns the field and, if that was the last root of that reference, the Garbage Collector (GC) [...]

Casting in .NET via object mutation

In this post, we will see how to make the following code fail: object it = new SomeStruct { Item = 1 };   Floatsy(it);   Console.WriteLine(((SomeStruct)it).Item); At runtime, it will throw an InvalidCastException!

Validating email addresses with .NET regex

I did validation in Haskell a while back, and since I recently discovered .NET’s “balancing groups” regex feature, it seems like it would be a good time to do it for .NET.

Unicode as she is broke

Do you think your string-handling code is robust? Are there any problems with the following snippets?