title: return the first longest string consisting of n consecutive strings taken in the array in c#
body: <p>I got this question in my interview:</p>
  <p>I got an array strarr of strings and an integer k. My task is to return the first longest string consisting of k consecutive strings taken in the array.</p>
  <p>Rules:n being the length of the string array, if n = 0 or k &gt; n or k &lt;= 0 return &quot;&quot;.</p>
  <h1>Example:</h1>
  <pre><code>LongestConsec([&quot;zone&quot;, &quot;abigail&quot;, &quot;theta&quot;, &quot;form&quot;, &quot;libe&quot;, &quot;zas&quot;, &quot;theta&quot;, &quot;abigail&quot;], 2) 
  </code></pre>
  <p>output should be &quot;abigailtheta&quot;</p>
  <p>Below is the code I have tried ..its not working.</p>
  <pre><code>public class LongestConsecutives
  {
      public static String LongestConsec(string[] strarr, int k)
      {
          string final = String.Join(&quot;&quot;, strarr.OrderByDescending(s=&gt;s.Length).Take(k)); 
          return final;
      }
  
      public static void Main()
      {
          string s1 = LongestConsec(new String[] { &quot;wlwsasphmxx&quot;, &quot;owiaxujylentrklctozmymu&quot;, &quot;wpgozvxxiu&quot; }, 2); //op=&quot;wlwsasphmxxowiaxujylentrklctozmymu&quot;
          string s2 = LongestConsec(new string[] { &quot;itvayloxrp&quot;, &quot;wkppqsztdkmvcuwvereiupccauycnjutlv&quot;, &quot;vweqilsfytihvrzlaodfixoyxvyuyvgpck&quot; }, 2);//op=&quot;wkppqsztdkmvcuwvereiupccauycnjutlvvweqilsfytihvrzlaodfixoyxvyuyvgpck&quot;
          string s3 = LongestConsec(new String[] { &quot;zone&quot;, &quot;abigail&quot;, &quot;theta&quot;, &quot;form&quot;, &quot;libe&quot;, &quot;zas&quot; }, -2);//op=&quot;&quot;
          string s4 = LongestConsec(new String[] { &quot;it&quot;, &quot;wkppv&quot;, &quot;ixoyx&quot;, &quot;3452&quot;, &quot;zzzzzzzzzzzz&quot; }, 3);//op=&quot;ixoyx3452zzzzzzzzzzzz&quot;
          string s5 = LongestConsec(new String[] { &quot;it&quot;, &quot;wkppv&quot;, &quot;ixoyx&quot;, &quot;3452&quot;, &quot;zzzzzzzzzzzz&quot; }, 15);//op=&quot;&quot;
          string s6 = LongestConsec(new String[] { &quot;it&quot;, &quot;wkppv&quot;, &quot;ixoyx&quot;, &quot;3452&quot;, &quot;zzzzzzzzzzzz&quot; }, 0);//op=&quot;&quot;
          string s7 = LongestConsec(new String[] { }, 3);//op=&quot;&quot;
          string s8 = LongestConsec(new String[] { &quot;zone&quot;, &quot;abigail&quot;, &quot;theta&quot;, &quot;form&quot;, &quot;libe&quot;, &quot;zas&quot;, &quot;theta&quot;, &quot;abigail&quot; }, 2);//op=&quot;abigailtheta&quot;
          string s9 = LongestConsec(new String[] { &quot;ejjjjmmtthh&quot;, &quot;zxxuueeg&quot;, &quot;aanlljrrrxx&quot;, &quot;dqqqaaabbb&quot;, &quot;oocccffuucccjjjkkkjyyyeehh&quot; }, 1);//op=&quot;oocccffuucccjjjkkkjyyyeehh&quot;
      }
  }
  </code></pre>