Issue I would like to work with ordered enumerables, and use interfaces as return types rather than the concrete types. I need to return an ordered set of objects. But, when using an IList<T> implementation I can not return IOrderedEnumerable<T>,
Continue readingTag: ienumerable
[SOLVED] How do I skip default JavaScript array serialization for IEnumerable types in Json.Net?
Issue Some custom types that implement IEnumerable don’t necessarily have backing collections. They could be generated dynamically, for example using ‘yield’ or LINQ. Here is an example: public class SOJsonExample { public class MyCustomEnumerable : IEnumerable<KeyValuePair<int,float>> { public List<int> Keys
Continue reading[SOLVED] Check a list of members to find whether any match a given property (e.g. password)
Issue My issue lies in this bit of code below. It functions as expected for null or whitespace issue but after porting my staff member login details over to an SQLite db, I’m now struggling to correctly test if the
Continue reading[SOLVED] How can I add an item to a IEnumerable<T> collection?
Issue My question as title above. For example IEnumerable<T> items = new T[]{new T("msg")}; items.ToList().Add(new T("msg2")); but after all it only has 1 item inside. Can we have a method like items.Add(item) like the List<T>? Solution You cannot, because IEnumerable<T>
Continue reading[SOLVED] Why doesn't Any() work on a c# null object
Issue When calling Any() on a null object, it throws an ArgumentNullException in C#. If the object is null, there definitely aren’t ‘any’, and it should probably return false. Why does C# behave this way? Solution When dealing with reference
Continue reading[SOLVED] Adding objects to IEnumerable
Issue Im making a basic CSV Reader. Im sepparating the header from the contents using header and data. Now, my lists contain data of the type person.: public class person { public int id; public string name; public int age;
Continue reading[SOLVED] How does the behavior of .Take() changes based on the interface reference I'm using on left. IQueryable vs IEnumerable
Issue Assume I’ve these sample codes IQueryable<Employee> data = context.Employees.Where(x => x.FullName != "Shekar Reddy"); var topEmp = data.Take(1); foreach (var item in topEmp) { Console.WriteLine(item.FullName); } and IEnumerable<Employee> data = context.Employees.Where(x => x.FullName != "Shekar Reddy"); var topEmp =
Continue reading[SOLVED] XML Linq – find a value of XElement from nested Descendants
Issue I have a sample of the following XML response from a REST call <GetHelloWorldResponse xmlns="http://www.helloworld.com/Services/HelloWorld"> <Available xmlns:i="http://www.w3.org/2001/XMLSchema-instance"> <Pool> <GameNumber>3081</GameNumber> <PoolDate>2022-04-20</PoolDate> <Category>MW</Category> <ScheduledCloseDate>2022-04-20T13:00:00</ScheduledCloseDate> <MinAllowedAST>2022-04-20T00:00:00</MinAllowedAST> <MaxAllowedAST>2022-04-20T23:59:00</MaxAllowedAST> <Randomised>false</Randomised> <Pool xmlns:a="http://www.helloworld.com/Services/Common"> <a:PoolId>10089269</a:PoolId> <a:RaceId>0</a:RaceId> <a:FixtureSeq>0</a:FixtureSeq> <a:RaceNum>0</a:RaceNum> <a:PoolType>FN</a:PoolType> <a:PoolStatus>CLOSED</a:PoolStatus> <a:PayPlacesCount>0</a:PayPlacesCount> <a:OverrideClosedInd>true</a:OverrideClosedInd> and I have this
Continue reading[SOLVED] Union two list by property
Issue I would like to merge two list without duplicates. It should distinct only by one property. I have a class: public class Test { public int Id { get; set; } public string Prop { get; set; } public
Continue reading[SOLVED] Delegate method signature with object and value assignment
Issue I’m trying to make an IEnumerable extension similar to one shown in Using LINQ's Zip with a closure that doesn't return a value by @Hakakou, however I’m trying to modify it to run a method of the first value,
Continue reading