Questions tagged [ienumerable]
IEnumerable, and its generic counterpart IEnumerable<T> are .NET interfaces for iterating (or enumerating) through a collection of items.
ienumerable
3,555
questions
2
votes
2
answers
69
views
Will LINQ Any() ever enumerate without arguments?
Given the following:
var nums = GetNums();
Console.WriteLine(nums.Any());
Console.WriteLine(string.Join(", ", nums));
static IEnumerable<int> GetNums()
{
yield return 1;
...
0
votes
3
answers
107
views
Which is more efficient Dictionary.TryGetValue or List.Any
I have a case where I have to find out if element belongs to a list or not in loop.
The straight forward way to do this is to call the Any method of the list, like this
public class Person
{
...
0
votes
1
answer
40
views
Why yield return null can't executed in Start() void
This problem is not always occurred.But when it happened,I can't find a way to fix it.
Here is the code:
void Start()
{
StartCoroutine(test());
}
IEnumerator test()
{
...
0
votes
2
answers
87
views
Unexpected behaviour with IEnumerable
In the code below I am mapping data that I got by paralelly downloading objects from AzureDevOps Rest Api. I noticed some weird bottlenecks in my code when transforming the mapDictionary to to an ...
0
votes
1
answer
37
views
Newtonsoft JSON error: "specified argument was out of the range of valid values"
I'm developing my game in Unity and chose to use the Newtonsoft JSON to facilitate saving and loading of game data. All entities are getting saved and loaded without a hitch, but the player data ...
0
votes
1
answer
49
views
Is there a way to create an empty instance that implements the IOrderedEnumerable? [duplicate]
The GetOrderedEnum function returns an enumeration ordered by fields from the names array. Everything is working, but I am worried about one question.
class Program {
class SomeData(int A, int B, ...
-1
votes
2
answers
91
views
How to find IEnumerable<T>.ToList() method by explicitly specifying type of parameters and then call it with a custom parameter type?
Let's say we have the following code (highly simplified modification of my own code):
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
namespace ...
0
votes
2
answers
80
views
Linq how can do null check in where clause?
This is simple linq query
datetime dob = "05152024";
var query = from row in maxLookupData.AsEnumerable()
where row.Field<DateTime>("bar")) <= dob
select row;
In ...
0
votes
1
answer
61
views
How to find item from one list in another
I have some product items in a cart. A customer has already placed an order for ONE of the items in his cart, in the past.
I am trying to get a list of orders he has placed in the past (accomplished ...
0
votes
0
answers
42
views
Why IEnamerable.ForEach statement seems invalid? [duplicate]
I wrote foreach loop with an IEnamerable object.
void PromptAsmName_(System.Reflection.Assembly asm) => logger.Prompt($"Asm: {asm.FullName})");
var domain = System.AppDomain....
4
votes
1
answer
139
views
Multi-yield mechanism in C#
I have a question over on Code Review SE where I'm struggling to work out how to refactor my enumerator method to be less of a complete mess.
I think part of the problem is I can't work out how to ...
2
votes
2
answers
115
views
Is it bad to call First() multiple times on an IEnumerable<T> that is actually a List<T>?
I found this method:
public async Task SomeMethod(IEnumerable<Member> members)
{
await DoSomething(members.First());
await DoSomethingElse(members.First());
}
It's being called like ...
0
votes
0
answers
43
views
How to import datfiles with filter based on datetimepicker with list dapper in VB.NET
I'm Trying to import datfiles with filter based on datetimepicker with list dapper in VB.NET
means there are 2 controls, namely DateTimePicker1 & DateTimePicker2
I use 2 control dateTimePicker ...
0
votes
0
answers
81
views
Function that reduces the number of element
I have a function, which merges elements if possible.
That is
public IEnumerable<TElement> TryMerge(IEnumerable<TElement> sequence){}
where the returned IEnumerable has less (or equal) ...
0
votes
0
answers
75
views
I dont understand what to do with: System.Text.Json.JsonException: 'The JSON value could not be converted to System.Collections.Generic.IEnumerable`1
I am writing a console application in C#, VS2022.
Where I receive a json string from Orchestrator (Uipath), try to deserialize it to an IEnumerable.
I've spent all day reading everything about this ...