Advertisement
Guest User

Untitled

a guest
Apr 25th, 2015
204
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.68 KB | None | 0 0
  1. using System;
  2. using ConsoleApplication1;
  3. using System.Collections.Generic;
  4. using System.Collections.ObjectModel;
  5. using System.Collections.Specialized;
  6. using System.Collections;
  7. using System.Linq;
  8.  
  9. /// <summary>
  10. /// Summary description for Class1
  11. /// </summary>
  12. ///
  13. namespace ExtensionMethods
  14. {
  15. public class MetodyRozszerzone
  16. {
  17. public MetodyRozszerzone()
  18. {
  19.  
  20. }
  21.  
  22. public static List<Czytelnik> NajwiecejKsiazek(this ObservableCollection<Wypozyczenie> wypozyczenia)
  23. {
  24. int rozmiar = wypozyczenia.Count;
  25. List<int> al = new List<int>();
  26. foreach (Wypozyczenie w in wypozyczenia)
  27. {
  28. int i = 0;
  29. foreach (Wypozyczenie y in wypozyczenia)
  30. {
  31. if (w.KtoMa == y.KtoMa) i++;
  32. }
  33. al.Add(i);
  34. }
  35. int k = 0;
  36. int [] array = al.ToArray();
  37. foreach (int l in array)
  38. {
  39. if (array[l] > k) k = array[l];
  40. }
  41. List<int> gdzie = new List<int>();
  42. foreach (int l in array)
  43. {
  44. if (array[l] == k) gdzie.Add(l);
  45. }
  46. array = gdzie.ToArray();
  47. List<Czytelnik> kto = new List<Czytelnik>();
  48. //Czytelnik[] kto ;
  49. int a = 0;
  50. int b = 0;
  51. foreach (Wypozyczenie w in wypozyczenia)
  52. {
  53. if(a==array[b])
  54. {
  55. kto[b] = w.KtoMa;
  56. b++;
  57. }
  58. a++;
  59. }
  60. kto.Distinct();
  61. return kto;
  62. }
  63. }
  64. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement