List or IList [closed]

If you are exposing your class through a library that others will use, you generally want to expose it via interfaces rather than concrete implementations. This will help if you decide to change the implementation of your class later to use a different concrete class. In that case the users of your library won’t need … Read more

How to remove elements from a generic list while iterating over it?

Iterate your list in reverse with a for loop: for (int i = safePendingList.Count – 1; i >= 0; i–) { // some code // safePendingList.RemoveAt(i); } Example: var list = new List<int>(Enumerable.Range(1, 10)); for (int i = list.Count – 1; i >= 0; i–) { if (list[i] > 5) list.RemoveAt(i); } list.ForEach(i => Console.WriteLine(i)); … Read more

How do I remove repeated elements from ArrayList?

If you don’t want duplicates in a Collection, you should consider why you’re using a Collection that allows duplicates. The easiest way to remove repeated elements is to add the contents to a Set (which will not allow duplicates) and then add the Set back to the ArrayList: Set<String> set = new HashSet<>(yourList); yourList.clear(); yourList.addAll(set); … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)