tagged [generic-list]

C# Update combobox bound to generic list

C# Update combobox bound to generic list I have a combobox on my form that is bound to a generic list of string like this: ``` private List mAllianceList = new List(); private void FillAllianceList() ...

11 Jan at 20:35

XML Serialization of List<T> - XML Root

XML Serialization of List - XML Root First question on Stackoverflow (.Net 2.0): So I am trying to return an XML of a List with the following: ``` public XmlDocument GetEntityXml() { StringW...

Replace an object in a list of objects

Replace an object in a list of objects In C#, if I have a `List`, and I have an object of type `T`, how can I replace a specific item in the `List` with the object of type `T`? Here is what I have tri...

How to OrderBy on a generic IEnumerable (IEnumerable<T>) using LINQ in C#?

How to OrderBy on a generic IEnumerable (IEnumerable) using LINQ in C#? In my generic repository I have below method: T is a Linq to Sql class and I want to be able to OrderBy on a particular property

5 May at 22:55

C# generic list <T> how to get the type of T?

C# generic list how to get the type of T? I'm working on a reflection project, and now I'm stuck. If I have an object of `myclass` that can hold a `List`, does anyone know how to get the type as in th...

10 Dec at 20:48

How to pass List<DerivedClass> when param type is List<BaseClass>?

How to pass List when param type is List? How can i pass a list which is a list of DerivedObjects where the Method is expecting a list of BaseObjects. I am converting the list `.ToList()` and am wonde...

4 Oct at 05:30

Saving from List<T> to txt

Saving from List to txt I want my program to read from two text files into one `List`. The `List` is sorting and cleaning duplicates. I want the `List` to save (after sorting and cleaning) to a txt fi...

21 May at 11:53

Thread Safety of C# List<T> for readers

Thread Safety of C# List for readers I am planning to create the list once in a static constructor and then have multiple instances of that class read it (and enumerate through it) concurrently withou...

15 Sep at 13:1

Converting a List of Base type to a List of Inherited Type

Converting a List of Base type to a List of Inherited Type I would be certain that this question addresses something that would have been brought up in a previous question, but I was unable to find it...

26 Mar at 17:12

Generic list of generic objects

Generic list of generic objects Let's say I have an object that represents a field of data, that object needs the following properties: Name, Type, Value, Length. Here is the object: ``` class Field {...

21 Oct at 10:1

WCF: Serializing and Deserializing generic collections

WCF: Serializing and Deserializing generic collections I have a class Team that holds a generic list: ``` [DataContract(Name = "TeamDTO", IsReference = true)] public class Team { [DataMember] priv...

Why Extra Copy in List<T>.AddRange(IEnumerable<T>)?

Why Extra Copy in List.AddRange(IEnumerable)? I'm looking at the open source code for [System.Collections.Generic.List](https://referencesource.microsoft.com/#mscorlib/system/collections/generic/list....

What's the implementation of List?

What's the implementation of List? I read this code: But I jumped to the definition(use VS2012) of `List` (in `System.Collections.Generic`), I found: ``` public class List : IList, ICollection, IEnume...

13 Jul at 05:25

Loop implementation of List.Contains() appears faster than the built-in one. Is it? If so, why?

Loop implementation of List.Contains() appears faster than the built-in one. Is it? If so, why? ([This question arises from a discussion that started here](https://stackoverflow.com/questions/16059391...

23 May at 12:25

Return Json from Generic List in Web API

Return Json from Generic List in Web API I build my list like this: ``` public static List SearchData(string searchString) { var searchResults = new List(); SqlDataReader drResults = FormulaUtilit...