Hi, As far as I know, this is not as simple as it shows up in C#. In CLR there are actually arrays and vectors, two similar but still different concepts. What we are talking here (SomeClass[]) is vector and is handled with special IL commands. For example, newarr creates vector and ldlen gets it length. Similar operations for array require newobj and method call. In c# every single-rank zero-based array produces vector. All vectors and arrays are objects (class instances) derived from the abstract class System.Array.
In the runtime, when you get Type object from the token (using GetTypeFromHandle) CLR actually builds a special object for specific vector. If you have Rotor, you can check ClassLoader::CreateArrayMethodTable method. Here are lines of interest: ArrayClass* pClass = ...; ... pClass->SetAttrClass (tdPublic | tdSerializable | tdSealed); // This class is public, serializable, sealed pClass->SetParentClass (g_pArrayClass->GetClass()); As you can see, vectors and arrays are always public, serializable and sealed, and this doesn't depend on element type visibility. They also has System.Array as base class, some methods such as Set, Get, Address, one or more constructors (different for vector and array), and so on. I agree with Dmitry, that public visibility of array is odd. I think this method should be corrected to get visibility from ElementType. Also, array should be Serializable if and only if element type is Serializable. Probably even nested aspect should be dervied from element type, i.e. array type is nested within the same type as element type, if any. Sincerely, Ilya Ryzhenkov > -----Original Message----- > From: Unmoderated discussion of advanced .NET topics. > [mailto:[EMAIL PROTECTED] On Behalf Of > Shawn A. Van Ness > Sent: Sunday, May 16, 2004 11:40 AM > To: [EMAIL PROTECTED] > Subject: Re: [ADVANCED-DOTNET] Visibility of an array type > and the element type > > At run-time, there is no such type as "SomeClass[]". There > is only System.Array -- and that type is, indeed, public. > > System.Array is a special type, in that it has what they call > "element type" > -- meaning that it's a type composed of (or referring to) > some other type (in this case, SomeClass). > > Make sense? > > Cheers, > -Shawn > http://www.windojitsu.com/ > > > -----Original Message----- > From: Dmitry Shaporenkov [mailto:[EMAIL PROTECTED] > Sent: Saturday, May 15, 2004 04:02 > Subject: Visibility of an array type and the element type > > Hi all, > > the output of the following program is a mystery for me: > > > using System; > > internal class SomeClass {} > > public class ReflectionTest > { > public static void Main () > { > SomeClass [] sc = new SomeClass [0]; > Console.WriteLine (sc.GetType().IsPublic); // True ??? > Console.WriteLine (sc.GetType().GetElementType > ().IsPublic); // False - OK > } > } > > > It seems that via Reflection I get that the array type > SomeClass[] has public visibility. I would expect it to have > the same visibility as its element type. Any ideas how this > can happen? > > > Regards, > Dmitry Shaporenkov > > =================================== > This list is hosted by DevelopMentor- http://www.develop.com > Some .NET courses you may be interested in: > > NEW! Guerrilla ASP.NET, 17 May 2004, in Los Angeles > http://www.develop.com/courses/gaspdotnetls > > View archives and manage your subscription(s) at > http://discuss.develop.com > > =================================== > This list is hosted by DevelopMentor╝ http://www.develop.com > Some .NET courses you may be interested in: > > NEW! Guerrilla ASP.NET, 17 May 2004, in Los Angeles > http://www.develop.com/courses/gaspdotnetls > > View archives and manage your subscription(s) at > http://discuss.develop.com > > =================================== This list is hosted by DevelopMentor╝ http://www.develop.com Some .NET courses you may be interested in: NEW! Guerrilla ASP.NET, 17 May 2004, in Los Angeles http://www.develop.com/courses/gaspdotnetls View archives and manage your subscription(s) at http://discuss.develop.com