Click here to Skip to main content
65,938 articles
CodeProject is changing. Read more.
Everything / IEnumerable

IEnumerable

IEnumerable

Great Reads

by dibley1973
This morning at work a colleague and myself discovered a slightly alarming difference between `IEnumerable.ForEach` and `List.ForEach` when we switched a collection type for a field in a C# ASP.NET MVC project.
by Jörgen Andersson
A propertymapping extension for DataReaders
by Ramesh Bevara
An overview of a helper class to build dynamic order by clause in LINQ query in C#
by Mikhail-T
A short one-line way to convert Array or List of any data into custom string via LINQ

Latest Articles

by dibley1973
This morning at work a colleague and myself discovered a slightly alarming difference between `IEnumerable.ForEach` and `List.ForEach` when we switched a collection type for a field in a C# ASP.NET MVC project.
by Jörgen Andersson
A propertymapping extension for DataReaders
by Ramesh Bevara
An overview of a helper class to build dynamic order by clause in LINQ query in C#
by Mikhail-T
A short one-line way to convert Array or List of any data into custom string via LINQ

All Articles

Sort by Score

IEnumerable 

by Ramesh Bevara
An overview of a helper class to build dynamic order by clause in LINQ query in C#
by Mikhail-T
A short one-line way to convert Array or List of any data into custom string via LINQ
by Namlak
string blah = string.Join(",", cities.Select(c=> c.Name));
by wgross
I would just use:string.Join(",", cities.Select(c=>c.Name))Since Version 4 of the Framework there is an overloaded versions of string.Join for IEnumerable too. It uses a StringBuilder internally and doesn't insert a seperator after the last element as well.I could't find the Join method...
by Richard Deeming
If you're stuck with .NET 3.5, you can use the Aggregate extension method[^]:string cities_string = cities.Aggregate(new StringBuilder(), (sb, c) =>{ if (0 != sb.Length) sb.Append(", "); sb.Append(c.Name); return sb;}, sb => sb.ToString());
by Kabwla.Phone
Ha! I get it....I am actually using an adaptation of this technique in production code.But the adapted code required a dept-first search and this original pattern is width-first.Which brings us these new and improved versions:public static List FindControlsWidthFirst( Control...
by Kabwla.Phone
Implemented with a queue and some newfangled yields.Since a queue does not have an 'EnqueueRange', we will still have to do a loop. Of course, enqueue range would be a nice extension method.Excusing the overhead created by the yield, this might use less memory if there are many controls. (Or...