title: LINQ join: Flexibility on list of structs
body: <p>apologises if the question is dumb, by I've want to know something to simplify my code:</p>
  
  <p>I have a few lists:</p>
  
  <pre><code>public struct structure
  {
       public string item1;
       public string item2;
       public string item3;
       public string item4;
  }
  public List &lt;structure&gt; listOfStruct=new List &lt;structure&gt;();
  public List &lt;string&gt; lista;
  public List &lt;string&gt; listb;
  </code></pre>
  
  <p>With below code I use the LINQ join to find matches in both lists:</p>
  
  <pre><code>                    query = from x in listOfStruct
                          join y2 in lista on x.item1 equals y2
                          select new
                          {
                              x.action
                          };
  
                          foreach (var item in query)
                          { 
                              Answer = item.answer;
                          }
  </code></pre>
  
  <p>The variable 'Answer' then is used for further processing. </p>
  
  <p>The thing is that somewhere else in my code I need to match another list with listOfStruct, but with another item of the struct:</p>
  
  <pre><code>                    query = from x in listOfStruct
                          join y2 in listB on x.item2 equals y2
                          select new
                          {
                              x.action
                          };
  
  
                          foreach (var item in query)
                          { 
                              Answer = item.answer;
                          }
  </code></pre>
  
  <p>I would like to write a function something like this</p>
  
  <pre><code>public string matchList(string actionListItem, string [] second_list){
                         query = from x in listOfStruct
                              join y2 in second_list on x.actionListItem equals y2
                              select new
                              {
                                  x.action
                              };
  
                              foreach (var item in query)
                              { 
                                  Answer = item.answer;
                              }
                              return Answer;
  }
  </code></pre>
  
  <p>and call if from anywhere in my program with something like below to be flexible and not write the same piece of code over and over again:</p>
  
  <pre><code>var action= matchList(string itemInlistOfStruct,string []secondList)
  </code></pre>
  
  <p>where "itemInListOfStruct" could be item1, item2...or item4 and "seconList" lista or listb.</p>
  
  <p>Is this possible? </p>