Type::IsNotPublic Property

Gets a value indicating whether the Type is not declared public.

Namespace:  System
Assembly:  mscorlib (in mscorlib.dll)

No code example is currently available or this language may not be supported.

Property Value

Type: System::Boolean
true if the Type is not declared public and is not a nested type; otherwise, false.

Do not use with nested types; use IsNestedPublic instead.

If the current Type represents a type parameter of a generic type, this property returns false.

TypeAttributes::VisibilityMask selects the visibility attributes.

This example shows the use of IsNotPublic to get the visibility of the type.

No code example is currently available or this language may not be supported.

This code produces the following output:

There are 27 members in System.IO.File.
Is System.IO.File public? False 

The following code example demonstrates why you cannot use IsPublic and IsNotPublic for nested classes.

No code example is currently available or this language may not be supported.

For nested classes, ignore the results of IsPublic and IsNotPublic and pay attention only to the results of IsNestedPublic and IsNestedPrivate. The reflection output for this code fragment would be as follows:

Class

IsNotPublic

IsPublic

IsNestedPublic

IsNestedPrivate

A

FALSE

TRUE

FALSE

FALSE

B

FALSE

FALSE

TRUE

FALSE

C

FALSE

FALSE

FALSE

TRUE

Silverlight

Supported in: 5, 4, 3

Silverlight for Windows Phone

Supported in: Windows Phone OS 7.1, Windows Phone OS 7.0

XNA Framework

Supported in: Xbox 360, Windows Phone OS 7.0

For a list of the operating systems and browsers that are supported by Silverlight, see Supported Operating Systems and Browsers.

Community Additions

ADD
Show: