What should I use an IEnumerable or IList? [duplicate]

Generally speaking, you should try and use the least specific type that suits your purpose. IEnumerable is less specific than IList (IList implements IEnumerable) so unless you want something specific from IList (such as Count as you suggest, or perhaps Add, Delete, etc), I’d use IEnumerable. One benefit of remaining with IEnumerable is that you … Read more

IEnumerable vs List – What to Use? How do they work?

IEnumerable describes behavior, while List is an implementation of that behavior. When you use IEnumerable, you give the compiler a chance to defer work until later, possibly optimizing along the way. If you use ToList() you force the compiler to reify the results right away. Whenever I’m “stacking” LINQ expressions, I use IEnumerable, because by … Read more

Can anyone explain IEnumerable and IEnumerator to me? [closed]

for example, when to use it over foreach? You don’t use IEnumerable “over” foreach. Implementing IEnumerable makes using foreach possible. When you write code like: it’s functionally equivalent to writing: By “functionally equivalent,” I mean that’s actually what the compiler turns the code into. You can’t use foreach on baz in this example unless baz … Read more

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