Click here to Skip to main content
15,897,032 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi there

Suppose you wanted to reference an instance of a generic such as BindingList<t> but don't care about the type of T.

For example, if you have a class called SomeClass with a constructor that wants an instance of BindingList<t> but doesn't care about what T's type is:

C#
public class SomeClass
{
    public SomeClass(BindingList<t> someList)
    { }
}

is there a way to do this without making SomeClass a generic: e.g SomeClass<t>
Posted
Updated 27-Aug-11 4:05am
v3

You could always make the type object
It does kind of destroy the advantages of strong typing though...
 
Share this answer
 
Comments
#realJSOP 27-Aug-11 10:26am    
5 - proposed as answer
It depends on what you want do do with the binding list. If you only care about the methods that one of the interfaces that BindingList implements, you could pass in an interface (e.g. IBindingList) instead of the BindingList.

Can you please ellaborate why you don't care about the type of T?

C#
public class SomeClass
{
  public SomeClass(IBindingList someList)
  { }
}
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900