generic (3,257)


What is the meaning of the type safety warning in certain Java generics casts?

What is the meaning of the type safety warning in certain Java generics casts?

What is the meaning of the Java warning ? Type safety: The cast from Object to List<Integer> is actually checking against the erased type List I get this warning when I try to cast an Object to a type…


c# - How to create a new object instance from a Type

One may not always know the Type of an object at compile-time, but may need to create an instance of the Type.How do you get a new object instance from a Type ?…


c# - Most Efficient Way to Test Object Type

I have values stored as strings in a DataTable where each value could really represent an int, double, or string(they were all converted to strings during an import process from an external data sou…


In C#, why can't a List<string> object be stored in a List<object> variable

It seems that a List object cannot be stored in a List variable in C#, and can't even be explicitly cast that way. List<string> sl=new List<string>(); List<object> ol; ol=sl; results in Cannot implici…



c# - Generic type conversion FROM string

I have a class that I want to use to store "properties" for another class. These properties simply have a name and a value. Ideally, what I would like is to be able to add typed properties, so that th…


c# - Generic type checking

Is there a way to enforce/limit the types that are passed to primitives?(bool, int, string, etc.) Now, I know you can limit the generic type parameter to a type or interface implementation via the whe…


c# - 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 in C#.NET and VB.NET?…


Sorting an IList in C#

So I came across an interesting problem today. We have a WCF web service that returns an IList. Not really a big deal until I wanted to sort it. Turns out the IList interface doesn't have a sort metho…


Generics in c# & accessing the static members of T

My question concerns c# and how to access Static memebers... Well I don't really know how to explain it(wich kind of is bad for a question isn't it?) I will just give you some sample code: Class te…


c# - List<BusinessObject> or BusinessObjectCollection?

Prior to C# generics, everyone would code collections for their business objects by creating a collection base that implemented IEnumerable IE: public class CollectionBase:IEnumerable and then woul…




type method class java parameter generics example with return list