In the code below, SomeClass is not public and the System.Array type sc is
public.

using System;
using System.Reflection;
using System.ComponentModel;
using System.ComponentModel.Design;

internal class SomeClass {}
public class ReflectionTest
{


        public static void Main()
        {
                Type myType = typeof(SomeClass);
                SomeClass [] sc = new SomeClass [0];
                Console.WriteLine(  myType.IsPublic);  //False
                Console.WriteLine (sc.GetType().IsPublic); //True

        }
}

Allaoua Cheraitia
[EMAIL PROTECTED]

-----Original Message-----
From: Unmoderated discussion of advanced .NET topics.
[mailto:[EMAIL PROTECTED] Behalf Of Shawn A. Van Ness
Sent: Saturday, May 15, 2004 9:40 PM
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

Reply via email to