C# Type IsPublic
Description
Type IsPublic
gets a value indicating whether the Type
is declared public.
Syntax
Type.IsPublic
has the following syntax.
public bool IsPublic { get; }
Example
The following example creates an instance of MyTestClass, checks for the IsPublic property, and displays the result.
using System;//from w w w .ja v a2 s . co m
public class MyTestClass
{
}
public class MyClass
{
public static void Main(string []args)
{
try
{
bool myBool = false;
MyTestClass myTestClassInstance = new MyTestClass();
Type myType = myTestClassInstance.GetType();
Console.WriteLine(myType.IsPublic);
}
catch (Exception e)
{
Console.WriteLine("\nAn exception occurred: {0}", e.Message);
}
}
}
The code above generates the following result.