Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using ConsoleApplication1;
- using System.Collections.Generic;
- using System.Collections.ObjectModel;
- using System.Collections.Specialized;
- using System.Collections;
- using System.Linq;
- /// <summary>
- /// Summary description for Class1
- /// </summary>
- ///
- namespace ExtensionMethods
- {
- public class MetodyRozszerzone
- {
- public MetodyRozszerzone()
- {
- }
- public static List<Czytelnik> NajwiecejKsiazek(this ObservableCollection<Wypozyczenie> wypozyczenia)
- {
- int rozmiar = wypozyczenia.Count;
- List<int> al = new List<int>();
- foreach (Wypozyczenie w in wypozyczenia)
- {
- int i = 0;
- foreach (Wypozyczenie y in wypozyczenia)
- {
- if (w.KtoMa == y.KtoMa) i++;
- }
- al.Add(i);
- }
- int k = 0;
- int [] array = al.ToArray();
- foreach (int l in array)
- {
- if (array[l] > k) k = array[l];
- }
- List<int> gdzie = new List<int>();
- foreach (int l in array)
- {
- if (array[l] == k) gdzie.Add(l);
- }
- array = gdzie.ToArray();
- List<Czytelnik> kto = new List<Czytelnik>();
- //Czytelnik[] kto ;
- int a = 0;
- int b = 0;
- foreach (Wypozyczenie w in wypozyczenia)
- {
- if(a==array[b])
- {
- kto[b] = w.KtoMa;
- b++;
- }
- a++;
- }
- kto.Distinct();
- return kto;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement