Click here to Skip to main content
15,890,845 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
hi, usually if we want use Inumerable, we will use follows.

C#
class program

{

static void main(string[] args)

{

List<int> oyears=new List<int>();

oyears.Add(100);

oyears.Add(101);

oyears.Add(102);

}

IEnumerable<int> enum=(IEnumerable<int>) oyears;

foreach(int i in enum)

{

console.wriline(i);

}


output :

101

102.



here IEnumerable<int> , int is datatype. so What is IEnumerable<T>. here T is What or stands for?..please help me out.
Posted
Updated 29-Aug-13 21:49pm
v2

The IEnumerable<T> interface is basically a type-safe IEnumerable. The T in this case is a so called generic type parameter. It defines that the IEnumerable will contain objects of type T.

There's a lot of resources to find on using generics on the internet, here's some to get started:

Introduction to Generics (C# Programming Guide)[^]
Difference between IEnumerable and IEnumerable<T>[^]
C# IEnumerable[^]
 
Share this answer
 
v2
Comments
Thomas Daniels 30-Aug-13 3:26am    
+5!

I also edited your answer, because the <T> was not visible because it was treated as a HTML tag.
Maarten Kools 30-Aug-13 6:06am    
Oh it was? It looked fine in the preview, I hadn't checked the final result to be honest (busy, busy) :/ Thanks!
IEnumerable<t> is an interface - you can't create an IEnumerable<t>, but rather must create some class that implements IEnumerable<t></t></t></t>
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900