views:

64

answers:

3

I currently have this method header:

public virtual void SetupGrid<T>() where T : class, new()
{

}

I want to pass in another anonymous class, I guess something like this:

public virtual void SetupGrid<T><T2>() where T,T2 : class, new()
{

}

How can I do this?

+5  A: 

These are called generics. Here's how you use several of them:

public virtual void SetupGrid<T, T2>() 
    where T : class, new()
    where T2 : class, new()

Start from this MSDN page for an introduction and much more info.

Anton Gogolev
Fastest compiler in the West :)
David
+2  A: 

You're talking about generic type arguments, not anonymous class types

Yes this is possible:

public virtual void SetupGrid<T,T2>() 
   where T : class, new()
   where T2: class, new()
{

}
jeroenh
+1  A: 

like this:

        public virtual void SetupGrid<T, T2>() where T : class, new() where T2 : class, new() {
David