What's the difference between IEnumerable<T> and List<T> ?
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.
Subscribe to:
Post Comments (Atom)
thanks 4 sharing.........
ReplyDeletewhy class is a abstract data type?
ReplyDeleteIn Abstract class we have Data & Function Member.
DeleteAll 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.
The abstract classes allows us to create classes that are incomplete and needs to be implemented
Deletein a derived class .
An abstract class can't be instantiated . It is just there to provide the derived classes a basic idea that what they need to implement.
very helpful. Thanks!
ReplyDeleteHere , the question is regarding why class is abstract data type?
ReplyDeleteA Class is abstract Data Type becauses it specifies what data members and member functions(methods) contain in it(class) ,but wont provide information on how those are implemented.
That makes Class Abstract and Class is User Defined DataType
So Its an Abstract Data Type
If I am not wrong, using Enumerator.MoveNext() also we can traverse through a collection of IEnumerable.
ReplyDelete
ReplyDeleteis class by default public or internal
Class By Default Internal
DeleteAbstract class is a class which contain both abstract & non abstract members (Abstract Methods declaration). When ever you want to implement a abstract method from abstract class you need to inherit the abstract class first & then implement the abstract method in the derived class. Abstract class should be a base class & we can not derived class as a abstract class.
ReplyDeleteHi this is LUCKEY..........
ReplyDeleteLet us consider there is a scenario that you have one Interface,in that there are so many defined methods(not implemented). Here you have to derive a class from that interface in this situation you need to implement all the methods of that interface but you don't know all the methods actual implementation, you know only one method implementation that you need, so for all that unknown methods you just put a key word "abstract" in your class and leave them, i hope every body know the abstract protocol, i.e if you declare one method as abstract in your class that class is an abstract class so you must declare that class as abstract class.remaining all routine things are discussed above by our friends............
Thanks®ards
------------------------
Luckey
Very used full interview questions.
ReplyDeleteIf i declare two variables with same name and same datatype in partial class is it return any errors if so what kind of errors those are?
ReplyDeletesame name variable defined in this scope.........if both are same scope.
ReplyDeleteOne more difference i would like to add. List is inherited from IList interface as well hence we can have random access using index where as IEnumerable implementaion does not allow such random access.
ReplyDeleteWhat are extension methods?
ReplyDeleteAdding some extra functionality to the existing method with out changing its original functionality is called as extension method.
Deletehow we can handle exception if occur in finally block
ReplyDeleteWhy ienumerable doesn't allow random access and what meant by random access in a list..
ReplyDeleteMy question is about method overloading, it was asked with different datatype
ReplyDeleteint add(int a, int b)
double add(int a, int b)
will it be method overloading