Using a list as a data source for DataGridView

First, I don’t understand why you are adding all the keys and values count times, Index is never used. I tried this example : var source = new BindingSource(); List<MyStruct> list = new List<MyStruct> { new MyStruct(“fff”, “b”), new MyStruct(“c”,”d”) }; source.DataSource = list; grid.DataSource = source; and that work pretty well, I get two … Read more

ICollection Vs List in Entity Framework

Entity Framework would use ICollection<T> because it needs to support Add operations, which are not part of the IEnumerable<T> interface. Also note that you were using ICollection<T>, you were merely exposing it as the List<T> implementation. List<T> brings along with it IList<T>, ICollection<T>, and IEnumerable<T>. As for your change, exposing via the interface is a … Read more

Why use ICollection and not IEnumerable or List on many-many/one-many relationships?

Usually what you choose will depend on which methods you need access to. In general – IEnumerable<> (MSDN: http://msdn.microsoft.com/en-us/library/system.collections.ienumerable.aspx) for a list of objects that only needs to be iterated through, ICollection<> (MSDN: http://msdn.microsoft.com/en-us/library/92t2ye13.aspx) for a list of objects that needs to be iterated through and modified, List<> for a list of objects that needs … Read more