title: Porting OnPropertyChanged from C# to VB.Net
body: <p>I have found some really interesting code for wiring up IPropertyChanged, To see the article click <a href="https://stackoverflow.com/questions/1315621/implementing-inotifypropertychanged-does-a-better-way-exist" title="Implementing INotifyPropertyChanged - does a better way exist?">here</a>.</p>
  
  <p>My problem is after I have converted it to VB.Net I am receiving a compiler error in OnPropertyChanged method on the last line - <em>OnPropertyChanged(body.Member.Name)</em></p>
  
  <blockquote>
    <p>Data type(s) of the type parameter(s) in method 'Protected Overridable Sub OnPropertyChanged(Of T)(selectorExpression As System.Linq.Expressions.Expression(Of System.Func(Of T)))' cannot be inferred from these arguments. Specifying the data type(s) explicitly might correct this error.</p>
  </blockquote>
  
  <p>Can someone help me correct the code to remove the error please?</p>
  
  <p>Original C# Version:</p>
  
  <pre><code>protected virtual void OnPropertyChanged&lt;T&gt;(Expression&lt;Func&lt;T&gt;&gt; selectorExpression)
  {
      if (selectorExpression == null)
          throw new ArgumentNullException("selectorExpression");
      MemberExpression body = selectorExpression.Body as MemberExpression;
      if (body == null)
          throw new ArgumentException("The body must be a member expression");
      OnPropertyChanged(body.Member.Name);
  }
  
  protected bool SetField&lt;T&gt;(ref T field, T value, Expression&lt;Func&lt;T&gt;&gt; selectorExpression)
  {
      if (EqualityComparer&lt;T&gt;.Default.Equals(field, value)) return false;
      field = value;
      OnPropertyChanged(selectorExpression);
      return true;
  }
  </code></pre>
  
  <p>After it has been converted to VB.Net</p>
  
  <pre><code>Protected Overridable Sub OnPropertyChanged(Of T)(selectorExpression As Expression(Of Func(Of T)))
      If selectorExpression Is Nothing Then
          Throw New ArgumentNullException("selectorExpression")
      End If
      Dim body As MemberExpression = TryCast(selectorExpression.Body, MemberExpression)
      If body Is Nothing Then
          Throw New ArgumentException("The body must be a member expression")
      End If
      OnPropertyChanged(body.Member.Name)//====this is the line with the compiler error======
  End Sub
  
  Protected Function SetField(Of T)(ByRef field As T, value As T, selectorExpression As     Expression(Of Func(Of T))) As Boolean
      If EqualityComparer(Of T).[Default].Equals(field, value) Then
          Return False
      End If
      field = value
      OnPropertyChanged(selectorExpression) 
      Return True
  End Function
  </code></pre>