tagged [generics]

Params IEnumerable<T> c#

Params IEnumerable c# Why cant I use an IEnumerable with params? Will this ever be fixed? I really wish they would rewrite the old libraries to use generics...

7 Mar at 03:25

C# constructor generic parameters inference

C# constructor generic parameters inference Why does C# infer generic parameters for methods but not for constructor? `new Tuple(5, 5)` vs. `Tuple.Create(5, 5)`

25 Mar at 10:0

What causes javac to issue the "uses unchecked or unsafe operations" warning

What causes javac to issue the "uses unchecked or unsafe operations" warning For example:

8 Mar at 20:44

CollectionBase vs generics

CollectionBase vs generics I am migrating an application from .NET 1.1 to .NET 2.0. Should I remove all uses of CollectionBase? If so, what is the best strategy for migration?

21 Dec at 15:53

Generics open and closed constructed types

Generics open and closed constructed types Recently I noticed that generic constructed types can be open and closed. But I do not understand what they actually mean. Can you give a simple example?

27 Jan at 10:23

How to cast List<Object> to List<MyClass>

How to cast List to List This does not compile, any suggestion appreciated. Compiler says: cannot cast `List` to `List`

18 Dec at 06:31

C# interface specfying a generic return type

C# interface specfying a generic return type I have something like: Is this possible???

13 Apr at 19:41

What does the term "Naked type constraint" refer to?

What does the term "Naked type constraint" refer to? Recently I have read a term "naked type constraint" in the context of Generics. What does it mean? Where do we use it?

2 Sep at 23:42

Get generic type of java.util.List

Get generic type of java.util.List I have; Is there a (easy) way to retrieve the generic type of the list?

21 Dec at 21:9

Check if 'T' inherits or implements a class/interface

Check if 'T' inherits or implements a class/interface Is there a way to test if T inherits/implements a class/interface?

23 May at 10:49

What does Method<ClassName> mean?

What does Method mean? I've seen this syntax a couple times now, and it's beginning to worry me, For example:

1 Jul at 16:44

Examples of usage of Generics in .Net (C#/VB.NET)

Examples of usage of Generics in .Net (C#/VB.NET) What are some examples of where you would use generics in C#/VB.NET and why would you want to use generics?

6 May at 14:59

Get the symmetric difference from generic lists

Get the symmetric difference from generic lists I have 2 separate List and I need to compare the two and get everything the intersection of the two lists. How can I do this (C#)?

5 Nov at 20:46

Instantiate Generic Type in C# class

Instantiate Generic Type in C# class Pretty basic question in C#, How do i do this?

8 Oct at 08:28

IEnumerable to IReadOnlyCollection

IEnumerable to IReadOnlyCollection I have `IEnumerable` and need to pass to a method as a parameter but this method takes `IReadOnlyCollection` Is it possible to convert `IEnumerable` to `IReadOnlyCol...

21 Aug at 04:17

List<T> or IList<T>

List or IList Can anyone explain to me why I would want to use IList over List in C#? [Why is it considered bad to expose List](https://stackoverflow.com/questions/387937)

23 May at 12:26

"where" keyword in class declaration in c sharp

"where" keyword in class declaration in c sharp Could anyone help me with the line `where TEntity : class, IEntity, new()` in the following class declaration.

7 Aug at 07:5

What does "where T : class, new()" mean?

What does "where T : class, new()" mean? Can you please explain to me what `where T : class, new()` means in the following line of code?

2 Oct at 18:53

What is the best way to iterate through a strongly-typed generic List<T>?

What is the best way to iterate through a strongly-typed generic List? What is the best way to iterate through a strongly-typed generic List in C#.NET and VB.NET?

19 Aug at 00:27

Populate list from array

Populate list from array if i have an array. can i populate a generic list from that array:

1 Apr at 01:53

IndexOf predicate?

IndexOf predicate? I want to find the index of an element in a list maching a certain predicate, is there a better way to do it than: ?

12 Apr at 08:33

Convert string to List<string> in one line?

Convert string to List in one line? I have a string: Is there a way to convert this to a `List` delimited by `,` in one line?

16 Feb at 01:8

What is the best way to clone/deep copy a .NET generic Dictionary<string, T>?

What is the best way to clone/deep copy a .NET generic Dictionary? I've got a generic dictionary `Dictionary` that I would like to essentially make a Clone() of ..any suggestions.

15 Apr at 13:54

getting type T from IEnumerable<T>

getting type T from IEnumerable is there a way to retrieve type `T` from `IEnumerable` through reflection? e.g. i have a variable `IEnumerable` info; i want to retrieve Child's type through reflection

26 May at 09:36

Equivalent of TreeSet in Java to C#.net

Equivalent of TreeSet in Java to C#.net I have Java code containing a `TreeSet`. I want to convert the code to C#. Which equivalent collection can I use? If there is none please suggest alternatives.

15 Feb at 12:22