What's the difference between IEnumerable<T> and List<T> ?

All Questions
ASP.NET
CSharp
SQL Server
WCF
HR Interview Questions
Didn't find what you are looking for? Search this
site, for frequently asked ASP.NET, C#, SQL Server, WCF
and HR Interview Questions



1. IEnumerable is an interface, where as List is one specific implementation of IEnumerable. List is a class.

2. FOR-EACH loop is the only possible way to iterate through a collection of IEnumerable, where as List can be iterated using several ways. List can also be indexed by an int index, element can be added to and removed from and have items inserted at a particular index.

3. IEnumerable doesn't allow random access, where as List does allow random access using integral index.

4. In general from a performance standpoint, iterating thru IEnumerable is much faster than iterating thru a List.


All Questions
ASP.NET
CSharp
SQL Server
WCF
HR Interview Questions
Didn't find what you are looking for? Search this
site, for frequently asked ASP.NET, C#, SQL Server, WCF
and HR Interview Questions

4 comments:

  1. why class is a abstract data type?

    ReplyDelete
    Replies
    1. In Abstract class we have Data & Function Member.
      All the Function member should be inherit by the derived class.
      We need the Class to be inherit and not to use as static and instance.

      Delete
  2. very helpful. Thanks!

    ReplyDelete

If you are aware of any other C# questions asked in an interview, please post them below. If you find anything missing or wrong, please feel free to correct by submitting the form below.

 
Disclaimer - Terms of use - Contact Us | Internet Marketing