c# - LINQ "zip" in String Array -


Say there are two arrays:

  string [] title = {"one" two three four"}; String [] user = {"rob", "", "john", ""};  

I have to filter the array given above when the user is empty, then join two or zip together in two. The final output should be:

  {"one: rob", "three: John"}  

How can LINQ be used?

It seems that you really want to "zip" data together (not to add) I.e. matches match; Is that right? If so, then simply:

  var qry = by title. Zip (user, (t, u) = & gt; new {title = t, user = u}) where! String Select the IsNullOrEmpty (row.User) row. Title + ":" + row.User; Foreach (string as in curie) console Limit (s); Using  

zip operation:

  // http://log.msdn.com/ericlippertarch// 2009 / 05/07 / zip-me-up.spacks public static IEnumerable & lt; TResult & gt; ZIP & lt; TFirst, Tsecond, TResult & gt; (This IEnumerable & lt; Tirsty & gt; First, IEnumerable & lt; Tsecond & gt; Second, Funk & lt; TFirst, Tsecond, TResult & gt; Results Selector) {If (first == empty) Throw new logic ("first"); If (second == empty) repeat the new argument ("second"); If (resultant == empty) remove new argument ("result secretary"); Return ZipIterator (first, second, result selector); } Private Stable IEnumerable & lt; TResult & gt; Geographer & lt; TFirst, TiesCand, TrashTouch & gt; (IEnumerable & lt; Tirst & gt; e1 = First using the Get Annetter ()) (IEnumerator & lt; tsecond & gt; e2 = second.GetEnumerator (user & lt; TFirst & gt; first, IEnumerable & lt; ; Tsecond & gt; second, function & lt; TFirst, Tsecond, TResult & gt;)) while (e1.MoveNext ()) & amp; Amp; Amp; & Amp; Amp; Amp;; E2.MoveNext ()) yield returns result selector (e1.Current, e2.Current); }  

Comments

Popular posts from this blog

c# - ListView onScroll event -

PHP - get image from byte array -

Linux Terminal Problem with Non-Canonical Terminal I/O app -