If you are dealing with a generic type definition you should only need to
call MakeGenericType
http://msdn2.microsoft.com/en-us/library/system.type.makegenerictype.aspx which
creates a closed version of your definition. Naturally a bit more work is
required (have to turn the string for the argument into a type) but
Type.GetType(string) http://msdn2.microsoft.com/en-us/w3f99sx1.aspx does
this fairly well.

Cheers,

Greg Young


On 6/7/06, Mike Andrews <[EMAIL PROTECTED]> wrote:

Yes, that worked great.  Thanks.

Now I have another similar question...

How can I reverse the process and pass a type to a generic method when all
I
have is a string?

so..

using my same method signature...

public virtual ItemType CreateSomething<ItemType>(...) where ItemType:
BaseSomething, New(){

...

}

How could I create a type that I could call this method with? or is that
even possible?

Thanks,
Mike



On 6/7/06, Stoyan Damov <[EMAIL PROTECTED]> wrote:
>
> typeof(ItemType).FullName?
>
> On 6/7/06, Mike Andrews <[EMAIL PROTECTED]> wrote:
> > Guys,
> >
> > Do any of y'all know of this is possible in C#?
> >
> > I have a generic method and I want to get the name of the type from
> method:
> >
> > public virtual ItemType CreateSomething<ItemType>(...) where ItemType:
> > BaseSomething, New(){
> >
> > ...
> >
> > }
> >
> > Now, within the method I want to know the typename of the type that
was
> > passed.
> > Is that possible?
> >
> > Thanks,
> > Mike
> >
> > ===================================
> > This list is hosted by DevelopMentor(r)  http://www.develop.com
> >
> > View archives and manage your subscription(s) at
> http://discuss.develop.com
> >
>
>
> --
>
> Cheers,
> Stoyan
>
> ===================================
> This list is hosted by DevelopMentor(r)  http://www.develop.com
>
> View archives and manage your subscription(s) at
> http://discuss.develop.com
>

===================================
This list is hosted by DevelopMentor(r)  http://www.develop.com

View archives and manage your subscription(s) at
http://discuss.develop.com




--
If knowledge can create problems, it is not through ignorance that we can
solve them.

Isaac Asimov

===================================
This list is hosted by DevelopMentorĀ®  http://www.develop.com

View archives and manage your subscription(s) at http://discuss.develop.com

Reply via email to