0
var zip = testNames.Zip(testNumbers, (code, state) => code + ": " + state); 

returns an IEnumerable of strings, how would I get IEnumerable string string?

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
  • Use backticks to format code. What type do you want? – SLaks Jun 17 '18 at 02:00
  • Make testNames a List() object. Sometimes testNames.AsEnumerable().Zip will work. Sometimes using testNames.Cast().Zip will solve issue. – jdweng Jun 17 '18 at 02:08
  • 4
    What do you mean by `IEnumberable string string`? That's not a valid type. Do you mean `IEnumerable<>` or `IEnumerable<(string, string)>`? – Enigmativity Jun 17 '18 at 02:18

1 Answers1

2

Here are you two choices, based on what you've given us in your question:

var testNames = new [] { "A", "B" };
var testNumbers = new [] { 1, 2 };

var zip1 = testNames.Zip(testNumbers, (code, state) => new { code, state });

var zip2 = testNames.Zip(testNumbers, (code, state) => (code, state));

Both are valid C#.

Based on reading your previous question you should need to get in to this .Zip scenario. You should be able to read your original data in a single query. My answer shows you how.

Enigmativity
  • 113,464
  • 11
  • 89
  • 172