I've been bitten a couple of times by statements in VB.NET (not sure if this effect exists in C#) that appear to be self-referencing, but when they're executed, they don't actually do anything because they require a target and one isn't provided. For example:
Dim MyString as string = "String to test"
' Neither of these lines do anything '
MyString.Replace(" ", "-")
MyString.Substring(0,5)
' This will return the original string, because neither statement did anything '
Messagebox.Show(MyString)
In both cases, it doesn't seem to bother .NET that the statement needs a target to assign the result to, and I don't give it one. Is there a reason that the IDE/compiler doesn't warn me of this effect, or that an exception "StatementDoesntDoAnything" isn't thrown? Since the code is formed in such a way that it will never change anything, it's clearly mis-typed.