title: Update a specific property with generics (Winform C#)
body: <p>Apologies as I am new to generics (which is what I believe is needed in this scenario).</p>
  
  <p>I want to pass the BindingList variable to a method that performs an update on a defined property, and then returns a pass/fail (true/false) value. This appears to be harder than I thought it would be, so could use some help. Here is working and non-working code.</p>
  
  <p>First, I have a class with a BindingList (working):</p>
  
  <pre><code>public class BookMetaData : INotifyPropertyChanged
  {
      private string _bookMetaDataTitle;
      [DescriptionLocalized(typeof(ResourcesClassBooks), "BookMetaDataTitleComment")]
      [DisplayNameLocalized(typeof(ResourcesClassBooks), "BookMetaDataTitleDisplayName")]
      public string BookMetaDataTitle { get { return _bookMetaDataTitle; } set { SetField(ref _bookMetaDataTitle, value, "BookMetaDataTitle"); } }
  
      #region handle property changes
      public event PropertyChangedEventHandler PropertyChanged;
      protected bool SetField&lt;T&gt;(ref T field, T value, string propertyName)
      {
          //if the value did not change, do nothing.
          if (EqualityComparer&lt;T&gt;.Default.Equals(field, value)) return false;
          //the value did change, so make the modification.
          field = value;
          return true;
      }
      protected virtual void OnPropertyChanged(string propertyName)
      {
          PropertyChangedEventHandler handler = PropertyChanged;
          if (handler != null) handler(this, new PropertyChangedEventArgs(propertyName));
      }
      #endregion
  }
  </code></pre>
  
  <p>Next, I create a variable that represents the binding list (working):</p>
  
  <pre><code>BindingList&lt;BookMetaData&gt; bookMetaData = new BindingList&lt;BookMetaData&gt;(); //metadata for the books
  </code></pre>
  
  <p>Prepare to send the class variable and specific property to update to a generic method. Please note, this technically works, but the remaining code does not:</p>
  
  <pre><code>private bool Test()
  {
      //the code below would probably be in a foreach loop and would not pass a single index.
      ProcessBookTitle(bookMetaData, 0, typeof(BookMetaData).GetProperty(nameof(BookMetaData.BookMetaDataCoverage)));
      return true;
  }
  </code></pre>
  
  <p>I want this generic method (is it called a method?) to update the BindingList class variable's specified property. If something goes wrong in the general business logic, that return false. Otherwise, return true (not working):</p>
  
  <pre><code>private void ProcessBookTitle&lt;T&gt;(BindingList&lt;T&gt; bindingList, int classIndex, PropertyInfo prop)
  {
      try
      {
          //do some things...
          //If I manually wrote the next line, it would look like this:
          //bookMetaData[0].BookMetaDataTitle = "My Book Title";
          bindingList[classIndex].prop = "My Book Title"; //error = 'T' does not contain the information for 'prop'...
          //maybe do some other things...
          return true; //cannot find a way to return bool.
      }
          catch
          {
              //something went wrong somewhere, so return false.
              return false; //does not work because cannot return a bool.
          }
      }
  </code></pre>
  
  <p>Is there a way I can send the name of the class variable and the property to update to another method? Also, is it possible to do this within a method that returns bool (and or some other way of returning success or failure)?</p>
  
  <p>Thanks in advance for any help you can provide.</p>
  
  <p><strong>EDIT:</strong> The requirement to return a bool is to ensure the passing method knew whether the overall process was successful. Updated code to show this.</p>