title: Why cannot convert null to type parameter T in c#?
body: <p>I'm converting a bunch of code from VB to C# and I'm running in to an issue with a method.  This VB method works great:</p>
  
  <pre><code>Public Function FindItem(ByVal p_propertyName As String, ByVal p_value As Object) As T
  
      Dim index As Int32
  
      index = FindIndex(p_propertyName, p_value)
  
      If index &gt;= 0 Then
          Return Me(index)
      End If
  
      Return Nothing
  
  End Function
  </code></pre>
  
  <p>It allow the return of Nothing(null) for T.</p>
  
  <p>The C# equivalent does not work:</p>
  
  <pre><code>public T FindItem(string p_propertyName, object p_value)
  {
    Int32 index = FindIndex(p_propertyName, p_value);
  
    if (index &gt;= 0) {
      return this[index];
    }
    return null;
  }
  </code></pre>
  
  <p>It won't compile with this error: </p>
  
  <blockquote>
    <p>The type 'T' must be a non-nullable value type in order to use it as parameter 'T' in the generic type or method <code>'System.Nullable&lt;T&gt;'</code></p>
  </blockquote>
  
  <p>I need to be able to have the same functionality or it will break a lot of code.  What am I missing?</p>