Thanks very much for the pointer.
I made a typo in my previous post. I meant the type is not known at
compile time but I'm glad you got the meaning.


On Jun 11, 4:19 pm, Tuna Toksoz <[email protected]> wrote:
>             var type = typeof (CriteriaImpl);
>             MethodInfo mi=type.GetMethod("List").MakeGenericMethod(new
> Type[]{yourruntimestuff});
>
> may help.
>
> Tuna Toksöz
> Eternal sunshine of the open source mind.
>
> http://devlicio.us/blogs/tuna_toksozhttp://tunatoksoz.comhttp://twitter.com/tehlike
>
> On Fri, Jun 12, 2009 at 2:15 AM, darren <[email protected]> wrote:
>
> > I can't use the List<T>() syntax because the type is unknown at
> > runtime.
>
> > On Jun 11, 4:14 pm, Tuna Toksoz <[email protected]> wrote:
> > > Try calling the generic method with reflection?
>
> > > Tuna Toksöz
> > > Eternal sunshine of the open source mind.
>
> >http://devlicio.us/blogs/tuna_toksozhttp://tunatoksoz.comhttp://twitt...
>
> > > On Fri, Jun 12, 2009 at 2:12 AM, darren <[email protected]> wrote:
>
> > > > I am trying to find a way to have the List method fill a generic list
> > > > without using the List<T> signature.  The lists I am using are generic
> > > > typed lists but are created dynamically at runtime using reflection.
>
> > > > Here's a snippet
>
> > > > ICriteria cr = session.CreateCriteria(objType);
> > > > var objList = Activator.CreateInstance(typeof(List<>).MakeGenericType
> > > > (objType)) as IList;
> > > > cr.List(objList);
>
> > > > This throws a type conversion exception in one of the ArrayHelper
> > > > methods.
>
> > > > I'm trying to avoid having to do an extra array copy for every List
> > > > call.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"nhusers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/nhusers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to