I'm just thinking out loud a bit here, so excuse me if this is a bad idea(tm).
I think another nice convenience feature would be a Nothing-safe If statement. I have some nested objects where it is possible that one or more of the nested objects are not set, requiring boilerplate short-circuiting code like this:
Code:
If obj1 Is Nothing Then Exit Sub
If obj1.obj2 Is Nothing Then Exit Sub
If obj1.obj2.obj3 Is Nothing Then Exit Sub
If obj1.obj2.obj3.obj4 Is Nothing Then Exit Sub
' All objects are set, continue work
If obj1.obj2.obj3.obj3.someProp > 0 Then
' Do Something
End If
C#, not sure about VB.Netthough, has a nice syntax for this. The ?. is used when you want the kind of behaviour you suggest but a normal . is the usual null behaviour.
Code:
if (ob1?.obj2?.Property > 2)
{
//will get here only if ob1 and obj2 aren't null and the Property is greater than 2
}
It is a massive help for writing clearer code, especially when calling members on potentially null objects.