Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / CLR / October 2003

Tip: Looking for answers? Try searching our database.

How to get one type's array type!

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
xiaorun huang - 15 Oct 2003 20:33 GMT
with Reflection API, I want to define a array of some type. if the type is
defined in else assembly, I can get the array type by call Type.GetType(
"TypeName[]" ). but with a type i am defining in same dynamic module, and i
cannot create type before define the array type. then how should i to get
the array type.

xiaorun huang
Girish Bharadwaj - 15 Oct 2003 14:39 GMT
> with Reflection API, I want to define a array of some type. if the type is
> defined in else assembly, I can get the array type by call Type.GetType(
[quoted text clipped - 3 lines]
>
> xiaorun huang

Maybe I am confused, You should be able to create a "Array" type use
that to stuff the types. Maybe I am wrong..

Signature

Girish Bharadwaj

Peter Koen - 15 Oct 2003 14:57 GMT
>> with Reflection API, I want to define a array of some type. if the
>> type is defined in else assembly, I can get the array type by call
[quoted text clipped - 6 lines]
> Maybe I am confused, You should be able to create a "Array" type use
> that to stuff the types. Maybe I am wrong..

you can use the static Method Array.CreateInstance

e.g.:
Array my3DArray=Array.CreateInstance( typeof(Object), 2, 3, 4 );
     for ( int i = my3DArray.GetLowerBound(0); i <=
my3DArray.GetUpperBound(0); i++ )
        for ( int j = my3DArray.GetLowerBound(1); j <=
my3DArray.GetUpperBound(1); j++ )
           for ( int k = my3DArray.GetLowerBound(2); k <=
my3DArray.GetUpperBound(2); k++ )
              my3DArray.SetValue( "abc" + i + j + k, i, j, k );

Signature

best regards

Peter Koen
-----------------------------------
MCAD, CAI/R, CAI/S, CASE/RS, CAT/RS
http://www.kema.at

xiaorun huang - 16 Oct 2003 15:59 GMT
Thanks to you! but I am not to create a instance of array, but to get the
array's type to use in some Emit API.

Mattias has told me what i want!

xiaorun huang

> >> with Reflection API, I want to define a array of some type. if the
> >> type is defined in else assembly, I can get the array type by call
[quoted text clipped - 18 lines]
> my3DArray.GetUpperBound(2); k++ )
>                my3DArray.SetValue( "abc" + i + j + k, i, j, k );
xiaorun huang - 16 Oct 2003 15:57 GMT
Yes! I want to create a "Arrary" type with element type is a type defining.
I have diffcult to express me full since english is not my mother language
:)!

Mattias has told me what i want!

xiaorun huang

> > with Reflection API, I want to define a array of some type. if the type is
> > defined in else assembly, I can get the array type by call Type.GetType(
[quoted text clipped - 6 lines]
> Maybe I am confused, You should be able to create a "Array" type use
> that to stuff the types. Maybe I am wrong..
Mattias Sj?gren - 15 Oct 2003 16:15 GMT
>but with a type i am defining in same dynamic module, and i
>cannot create type before define the array type. then how should i to get
>the array type.

Have you tried using ModuleBuilder.GetType() instead?

Mattias

Signature

Mattias Sjögren [MVP]  mattias @ mvps.org
http://www.msjogren.net/dotnet/
Please reply only to the newsgroup.

xiaorun huang - 16 Oct 2003 15:54 GMT
Yes, ModuleBuilder.GetType( ) is what I want!

Thanks!

xiaorun huang

> >but with a type i am defining in same dynamic module, and i
> >cannot create type before define the array type. then how should i to get
[quoted text clipped - 3 lines]
>
> Mattias

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.