title: Creating method within Custom Class for Primary ID lookup based off other field
body: <p>This should be a pretty easy question.</p>
  <p><strong>Context:</strong>
  I have a custom class that stores some information from a Database.
  It stores a primary key (ID) and description/name.
  I want to return the primary key by searching for a description/name.</p>
  <p>This is my 1st C# program.</p>
  <p>I am trying to use LINQ where to do the lookup.
  It made sense to me that I should make the method for this be apart of the custom class that I created. <strong>Do you agree?</strong></p>
  <p>Where would you recommend I declare this method? Declaring within the class seems like the correct thing to do<br />
  <strong>Why does the &quot;This.Where&quot; syntax not work? - I suppose its because its not a List&lt; ClassTypeHere&gt;</strong></p>
  <pre><code>class DM_DistEquip
      {
          public int ixPanel; //stores ID_Key relation to panel name
          public string sDescription; //stores name of panel
          public int iPanelType; //store ID_Key for type of panel
  
          public int distLookup(string pnl)
          {
              var dist = this.Where(x =&gt; x.sDescription == pnl).Select(y =&gt; y.ixPanel ).ToList(); //Lookup the primary key (ID) of the panel based of name of panel
              return dist; //return ID of the Panel Name
          }//end of method
      }
  </code></pre>