tagged [ienumerable]
return single instance object as IEnumerable
return single instance object as IEnumerable I have in instance of class foo and i want to return it as IEnumerable. Can i do it without creating a new list etc.. Perhaps something like the following:
- Modified
- 3 Aug at 18:6
Why was IEnumerable<T> made covariant in C# 4?
Why was IEnumerable made covariant in C# 4? In earlier versions of C# `IEnumerable` was defined like this: Since C# 4 the definition is: - - `string[]
- Modified
- 21 Nov at 07:1
Code for adding to IEnumerable
Code for adding to IEnumerable I have an enumerator like this How can I add a page (eg: D:\newfile.txt) to it? I have tried `Add`, `Append`, `Concat` etc But nothing worked for me.
- Modified
- 23 Jul at 08:37
IEnumerable from IEnumerator
IEnumerable from IEnumerator I have writen about custom `IEnumerator`. Whats the simplest way to make `IEnumerable` from it ? Ideal solution (one line of code) would be if there was some class for tha...
- Modified
- 21 Jan at 21:47
Is the order of objects returned by FOREACH stable?
Is the order of objects returned by FOREACH stable? Is it safe to assume that two itterations over the same collection will return the objects in the same order? Obviously, it is assumed that the coll...
- Modified
- 26 Feb at 17:13
What should I use an IEnumerable or IList?
What should I use an IEnumerable or IList? Can anyone tell me when I should use either. For example, I think I should use an IList when I want to access the .Count of the collection or an individual i...
- Modified
- 12 Jul at 13:15
Freely convert between List<T> and IEnumerable<T>
Freely convert between List and IEnumerable How can I convert a `List` to an `IEnumerable` and then back again? I want to do this in order to run a series of LINQ statements on the List, e. g. `Sort()...
- Modified
- 5 Dec at 19:27
How to Sort IEnumerable List?
How to Sort IEnumerable List? I have the following list: The `Car` object has a model and a year. I want to sort this list by model and then year (within model). What is the best way of doing this?
- Modified
- 24 Feb at 15:7
If yield return never occurs, is null returned?
If yield return never occurs, is null returned? The method returns IEnumerable via a yield return statement. If the yield statement never occurs (it's inside conditional logic), will the method return...
- Modified
- 6 Aug at 19:37
Chart of IEnumerable LINQ equivalents in Scala?
Chart of IEnumerable LINQ equivalents in Scala? > [LINQ analogues in Scala](https://stackoverflow.com/questions/3785413/linq-analogues-in-scala) I am looking for chart which shows equivalents in Sca...
- Modified
- 23 May at 12:9
What is the best wayto add single element to an IEnumerable collection?
What is the best wayto add single element to an IEnumerable collection? I'm surprised to see that there does not appear to be a method to add a single element to an IEnumerable collection. How can I a...
- Modified
- 15 Nov at 22:38
Creating the IEnumerable<KeyValuePair<string, string>> Objects with C#?
Creating the IEnumerable> Objects with C#? For testing purposes, I need to create an `IEnumerable>` object with the following sample key value pairs: What is the easiest approach to do this?
- Modified
- 17 Mar at 05:16
Cannot apply indexing with [] to an expression of type 'System.Collections.Generic.IEnumerable<>
Cannot apply indexing with [] to an expression of type 'System.Collections.Generic.IEnumerable Is there any specific reason why indexing is not allowed in IEnumerable. I found a workaround for the pro...
- Modified
- 19 May at 04:51
Check that all items of IEnumerable<T?> has the same value using LINQ
Check that all items of IEnumerable has the same value using LINQ I have a nullable type, e.g. `SomeEnum?` and a set of values, e.g. `IEnumerable`. How to check that all items has the same value using...
- Modified
- 7 Jul at 19:47
Why doesn't IEnumerable<T> have FindAll or RemoveAll methods?
Why doesn't IEnumerable have FindAll or RemoveAll methods? It seems to me that a lot of the extension methods on `IList` are just as applicable to `IEnumerable` - such as `FindAll` and `RemoveAll`. Ca...
- Modified
- 7 Jan at 13:36
How to group items by index? C# LINQ
How to group items by index? C# LINQ Suppose I have How do I get them grouped into pairs? Preferably using LINQ
- Modified
- 17 Aug at 21:6
What is the difference between IQueryable<T> and IEnumerable<T>?
What is the difference between IQueryable and IEnumerable? What is the difference between `IQueryable` and `IEnumerable`? --- See also [What's the difference between IQueryable and IEnumerable](https:...
- Modified
- 23 May at 12:26
Index in the Select projection
Index in the Select projection I would like my index to start from a number count greater than 0 while doing something like this: so my output becomes: Is it possible to do?
- Modified
- 28 Jan at 15:49
How can I create a singleton IEnumerable?
How can I create a singleton IEnumerable? Does C# offer some nice method to cast a single entity of type `T` to `IEnumerable`? The only way I can think of is something like: And I guess there should b...
- Modified
- 10 Feb at 16:57
How can I add an item to a IEnumerable<T> collection?
How can I add an item to a IEnumerable collection? My question as title above. For example but after all it only has 1 item inside. Can we have a method like `items.Add(item)` like the `List`?
- Modified
- 7 Oct at 15:38
How to append enumerable collection to an existing list in C#
How to append enumerable collection to an existing list in C# i have three functions which are returning an IEnumerable collection. now i want to combine all these into one List. so, is there any meth...
- Modified
- 1 Nov at 07:24
Why doesn't Any() work on a c# null object
Why doesn't Any() work on a c# null object When calling [Any()](http://msdn.microsoft.com/en-us/library/bb337697) on a null object, it throws an ArgumentNullException in C#. If the object is null, the...
- Modified
- 11 Oct at 14:52
How to get the first element of IEnumerable
How to get the first element of IEnumerable Is there a better way getting the first element of IEnumerable type of this: This is the exact declaration of the type:
- Modified
- 23 Feb at 09:49
How to concatenate two IEnumerable<T> into a new IEnumerable<T>?
How to concatenate two IEnumerable into a new IEnumerable? I have two instances of `IEnumerable` (with the same `T`). I want a new instance of `IEnumerable` which is the concatenation of both. Is ther...
- Modified
- 11 Mar at 00:23
Create IEnumerable<T>.Find()
Create IEnumerable.Find() I'd like to write: Can I accomplish this with extension methods? The following fails because it recursively calls itself rather than calling IList.Find(). Thanks!
- Modified
- 3 Jun at 20:46