It's a dirty job but someone has to do it

Well here is just more of the same, Stephen posted about querying an item to see whether it's "dirty" or not.  Here is the .NET equivalent. I didn't actually test these this time so your feedback is welcome.

Visual Basic

 Public Function IsItemDirty(ByVal itm As Object) As Boolean
  Dim typeDispatch As Type = itm.GetType()
  Dim dispidIsDirtyMemberName As String = String.Format("[DispID={0}]", _ 
  Dim retVal As Boolean = False
    retVal = typeDispatch.InvokeMember(dispidIsDirtyMemberName, _ 
        System.Reflection.BindingFlags.InvokeMethod _ 
        Or System.Reflection.BindingFlags.GetProperty, _
        Nothing, _
        itm, _
  Catch comEx As System.Runtime.InteropServices.COMException

  End Try
End Sub



 public bool IsItemDirty(object itm)
  Type typeDispatch = itm.GetType();
  string dispidIsItemDirtyMemberName = String.Format("[DispID={0}]", 0xF024);
  bool retVal = false;

    retVal = (bool)typeDispatch.InvokeMember(dispidIsItemDirtyMemberName, 
        System.Reflection.BindingFlags.InvokeMethod |
  catch(System.Runtime.InteropServices.COMException comEx)

  return retVal;