Advertisement
Heretiiik

Untitled

Oct 24th, 2019
127
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.45 KB | None | 0 0
  1.  
  2. using System;
  3. using System.Collections.Generic;
  4. using System.Text;
  5. using System.Linq;
  6.  
  7. public static string Repeat(this string str, int n) {
  8.     return new string('X', n).Replace("X", str + '\n');
  9. }
  10.  
  11.  
  12. List<string> list1 = new List<string>() {"foo", "baz", "bar", "yada"};
  13. List<int> list2 = new List<int>() { 1,2,3,4,5 };
  14.  
  15. var result = list1.Zip(list2, (first, second) => first.Repeat(second));
  16.  
  17. foreach (var r in result) {
  18.     Console.WriteLine(r);  
  19. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement