
Signature
Mattias Sjögren [MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.
> Since TypeBuilder derives from Type, you can try using typeBuilder
> there.
But if I simply use the TypeBuilder I have, I will end up defining a
function looking like this:
public static A Func(A a) {...}
which is not what I need. How do I, starting from the TypeBuilder for A
that I have, get to a TypeBuilder for array-of-A and managed-pointer-to-A?
Can you give an example?
Robert Jordan - 18 Sep 2005 16:27 GMT
Hi,
>>Since TypeBuilder derives from Type, you can try using typeBuilder
>>there.
[quoted text clipped - 7 lines]
> that I have, get to a TypeBuilder for array-of-A and managed-pointer-to-A?
> Can you give an example?
You need the get the incomplete types from the ModuleBuilder:
Type arrayType = moduleBuilder.GetType ("A[]");
Type refType = moduleBuilder.GetType ("A&");
MethodBuilder mb = typeBuilder.DefineMethod("Func",
MethodAttributes.Public|MethodAttributes.Static,
arrayType, new Type[]{refType});
Rob
Corey Kosak - 18 Sep 2005 17:58 GMT
Yee-haw! Works great. Thank you!
> You need the get the incomplete types from the ModuleBuilder:
> Type arrayType = moduleBuilder.GetType ("A[]");
> Type refType = moduleBuilder.GetType ("A&");