title: C# How to use FirstOrDefault with an array while unable to have System.Linq in the namespace?
body: <p>The code provided here works when I test it in the IDE, but the software itself which will be using this code doesn't give me the possibility declare <code>using System.Linq</code>. I'm stuck trying to figure out how to use this else I'll have to go back to a solution I'd rather not use because it has a lower accuracy rate.</p>
  
  <p>The issue is here</p>
  
  <pre><code>var stringMatch = sArray.FirstOrDefault(titleID.Contains);
  </code></pre>
  
  <p>I'm not sure how to properly provide the references. I think it should be something along the ways of <code>System.Linq.Enumerable</code>... but it's the first time I'm dealing with such an issue so any help much appreciated.</p>
  
  <pre><code>        string TakeEndPeriod = "";
          string NewEndPeriod = "";
          string FindEndSpace = "";
          string GetEndPeriod = "";
          string titleID = "document for the period ended December 31 2014";
  
          string s1 = "ended ";
          string s2 = "Ended ";
          string s3 = "Ending ";
          string[] sArray = new [] { s1, s2, s3};
  
  
               var stringMatch = sArray.FirstOrDefault(titleID.Contains);
              if (stringMatch != null)
              {
                  TakeEndPeriod = titleID.Substring(titleID.LastIndexOf(stringMatch));
                  FindEndSpace = TakeEndPeriod.Substring(TakeEndPeriod.IndexOf(" "));
                  GetEndPeriod = FindEndSpace.Substring(1);
  
                 string[] formatArray = new[] { "dd MMMM yyyy", "MMMM dd yyyy" };
  
                  DateTime ModEndPeriod;
                  if (!DateTime.TryParseExact(GetEndPeriod,
                                              formatArray,
                                              System.Globalization.CultureInfo.InvariantCulture,
                                              System.Globalization.DateTimeStyles.None,
                                              out ModEndPeriod))
                  {
                          //parsing failed
  
                  }
  
                  NewEndPeriod = ModEndPeriod.ToString("yyyy-MM-ddT00:00:00Z");
  </code></pre>
  
  <p><strong>EDIT:</strong></p>
  
  <p>error message I'm getting:</p>
  
  <pre><code>'System.Array' does not contain a definition for 'FirstOrDefault' and no extension
   method 'FirstOrDefault' accepting a first argument of type 'System.Array' could be
   found (are you missing a using directive or an assembly reference?)
  </code></pre>
  
  <p><strong>EDIT:</strong></p>
  
  <p>This is the solution I got from the dev support managing the software:</p>
  
  <pre><code>String Title = "document for the period Ending December 31 2014";
              Match M = Regex.Match(Title, ".*?(?i)(ended|ending)(.*)");//Case insensitive search for "ended" and "ending"
              if (M.Groups.Count == 3)
              {
                  //Match OK
                  DateTime DT = DateTime.Parse(M.Groups[2].Value);
                  //The variable DT will now have the parsed date.
                  Console.WriteLine(DT.ToString("yyyyMMdd"));
              }
  </code></pre>