ilist

Adding an IList item to a particular index number

Our Client's database returns a set of prices in an array, but they sometimes don't include all prices, i.e., they have missing elements in their array. We return what we find as an IList, which works great when we retrieve content from the database. However, we are having difficulties setting the elements in the proper position in the...

How can i do something like IList<T>.Contains(OtherObjectType) ?

Hi, I have the following classes: Client ClientCacheMedia ( contains Client, Media and some other parameters so it is the link between the media and the client) Media where client contains an IList. Now what i would like to do, is have a way to check if this ilist contains a certain media so : Client.ClientCacheMedia.Contains(MyMed...

List.ForEach method and collection interfaces

In .NET 3.5 List<> gains a ForEach method. I notice this does not exist on IList<> or IEnumerable<> what was the thinking here? Is there another way to do this? Nice and simple short way to do this? I ask because I was at a talk where the speaker said always use the more general interfaces. But why would I use IList<> as a return type i...

Model Binding to a List using non-sequential indexes. Can I access the index later?

I'm following Phil's great tutorial on model binding to a list. I use input names like this: book[5804].title book[5804].author book[1234].title book[1234].author This works well and the data gets back to the model just fine, populating a list of books. What I'm looking for is a way to get access in the model to the index that was u...

IQueryable<t> Or IList<t>

Hi , I have some methods in my BLL that fetch some records from database and pass it to UI for binding to Data Controls such as Gridview or ... I could choose my return data type of the methods whether IQueryable<t> or Ilist<t> . My question is which one would be better for me and why ? Actually i don't know the difference between t...

Using Type.GetType(string) in IList<T>

Hello all, Since I can't make any comments (only post an answer) to this post, I'll post a new question. I followed the instructions from mentioned post, but the code produces an error. The code: Type t = Type.GetType(className); Type listType = typeof(List<>).MakeGenericType(t); IList list = (IList)Activator.CreateInstance(listType)...

Generic Delegate and IList<T>

Hi, I want to implement a delegate solution for Bubble sort. I have this code: public delegate void SortHandler<T>(IList<T> t); public static void Sort<T>(IList<T> arr, SortHandler<T> func) { func(arr); } int[] arr2 = { 10,1,2,3,4 }; CollectionHelper.Sort<int>(arr2, bubble_sort); bubble sort function signature is: static void bubbl...

Choosing the right Collection/List for my repository

I have a repository: public ObservableCollection<ProjectExpenseBO> GetProjectExpenses() { //Get by query IQueryable<ProjectExpenseBO> projectExpenseQuery = from p in _service.project_expense from e in _service.vw_employee where p.employee_id == e.employee_id select new ProjectExpenseBO() { ...

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 item, correct? Thank you. ...

Creating a class field of type IList<>?

I'm trying to create a POCO object called Friend.cs. I can't seem to create inline properties for the IList. public class User { public string ID { get; set; } public string Name { get; set; } public string Rating { get; set; } public string Photo { get; set; } public string Reputation { get; ...

IList<T> does not have "where"

In a specific project at my work, I have a method that returns IList. But this interface does not contain where, or FindAll filters. However, when I open a new project, IList contains all. What is the difference? ...

How to deep clone objects containing an IList property using AutoMapper

I am trying to deep clone the following class using AutoMapper: public class MainData { public MainData() { Details = new List<Detail>(); } public int Id { get; private set; } public DateTime LastUpdate { get; private set; } public IList<Detail> Details { get; private set; } public int Prop1 { get; s...

Set Binding Source DataSource to Generic IList<> Error

If I want to set the DataSource property on a BindingSource to an IList<>, do I need an explicit cast as the following error message says or am I doing something wrong? interface IView { IList<OrderItems> BindingSource { get; set;} } public partial class Form1 : Form, IView { public Form1() {...

VB.Net - how can i get the type of the object contained in an List

If I have a list... dim l as List(of MyClass) = new List(of MyClass) and I want to get the type of the objects contained in the list, how do I do that? The obvious answer, that doesn't seem to be possible from my actual implementation, would be to do something like this... public function GetType(byval AList as IList(of GenericType)...

C#, ArrayList Property to List field

Hello, I have the following Field: private IList<Modulo> modulos; and the following Property: public virtual ArrayList XmlModulos { get { if (modulos == null) return new ArrayList(); var aux = new ArrayList(); foreach (Modulo m in modulos) aux.Add(m); ...

Remove foreach - c# code-optimization

How to optimize this code? ParentDoglist, ChildDoglistis - Ilist. dogListBox - List Box foreach (Dog ParentDog in ParentDoglist) { foreach (Dog ChildDog in ChildDoglist) { if(ParentDog.StatusID==ChildDog.StatusID) dogListBox.Items.Add(new ListItem(ParentDog.Name, ParentDog.Key)); } } EDIT: ParentDogTypeList, DogTypeList were ...

Class that implements an interface with IList of another interface property...how to?

I have two interfaces like these: public interface IMyInterface1 { string prop1 { get; set; } string prop2 { get; set; } } public interface IMyInterface2 { string prop1 { get; set; } IList<IMyInterface1> prop2 { get; set; } } I have defined two classes that implement the interfaces: public class MyClass1 : IMyInterfa...

Consolidating and filtering iList items, looking for paterns, practices, or existing methods.

I'm reading a binary file into a bindinglist of (t); to be bound to a datagridview. Each line in the file represents a single transaction but I need to consolidate and or filter transactions that meet certain criteria. I know how to do this from a mechanical standpoint (looping the list while adding each item, and adding a new item, o...

Unable to use IList<xxxObject> to send data from Rest WCF service to Java client consumed by Android

Hello, I run Rest WCF Service(webHttpBinding) that returns IList and two clients. First client is WCF Client in .net, which able to receive the list of objects correctly. Second client is Java Client consumed by Android, which able to receive the Object correctly, but not a list of objects. Your help will be very appreciated. ...

Using LINQ-to-NHibernate Sort an IQueryable of T based on a property value within T's Children

Though the project in which I'm having this issue addresses a different domain, I've found a metaphor that may help to present my question clearly: Let's say that you had to develop a Forum web site, and it was a requirement that the default view for the site needs to display Forum Threads ordered by the threads with the most recent For...