Type.IsPublic プロパティとは? わかりやすく解説

Type.IsPublic プロパティ

Typeパブリックとして宣言されているかどうかを示す値を取得します

名前空間: System
アセンブリ: mscorlib (mscorlib.dll 内)
構文構文

解説解説
使用例使用例

MyTestClassインスタンス作成しIsPublic プロパティチェックして結果表示する例を次に示します

Imports System
Imports Microsoft.VisualBasic
Namespace SystemType
    ' Declare MyTestClass as public.
    Public Class MyTestClass
    End Class 'MyTestClass
    Public Class [MyClass]
        Public Shared Sub
 Main()
            Try
                Dim myBool As Boolean
 = False
                Dim myTestClassInstance As
 New MyTestClass()
                ' Get the type of myTestClassInstance.
                Dim myType As Type = myTestClassInstance.GetType()
                ' Get the IsPublic property of myTestClassInstance.
                myBool = myType.IsPublic
                Console.WriteLine(ControlChars.Cr + "Is {0 public?
 {1}.", myType.FullName, myBool.ToString())
            Catch e As Exception
                Console.WriteLine(ControlChars.Cr + "An exception
 occurred: {0}", e.Message.ToString())
            End Try
        End Sub 'Main
    End Class '[MyClass]
End Namespace 'SystemType 
using System;
namespace SystemType
{
    // Declare MyTestClass as public.
    public class MyTestClass
    {
    }
    public class MyClass
    {
        public static void
 Main(string []args)
        {
            try
            {
                bool myBool = false;
                MyTestClass myTestClassInstance = new MyTestClass();
                // Get the type of myTestClassInstance.
                Type   myType = myTestClassInstance.GetType();
                // Get the IsPublic property of the myTestClassInstance.
                myBool = myType.IsPublic;
                Console.WriteLine("\nIs {0} public? {1}.",
 myType.FullName, myBool.ToString ());
            }
            catch (Exception e)
            {
                Console.WriteLine("\nAn exception occurred: {0}", e.Message);
            }
        }
    }
}
using namespace System;

namespace SystemType
{

   // Declare MyTestClass as public.
   public ref class MyTestClass{};

   public ref class MyClass{};

}

int main()
{
   try
   {
      bool myBool = false;
      SystemType::MyTestClass^ myTestClassInstance = gcnew SystemType::MyTestClass;
      
      // Get the type of myTestClassInstance.
      Type^ myType = myTestClassInstance->GetType();
      
      // Get the IsPublic property of the myTestClassInstance.
      myBool = myType->IsPublic;
      Console::WriteLine( "\nIs {0} public? {1}.", myType->FullName,
 myBool.ToString() );
   }
   catch ( Exception^ e ) 
   {
      Console::WriteLine( "\nAn exception occurred: {0}", e->Message
 );
   }

}

package SystemType; 

import System.*;

// Declare MyTestClass as public.
public class MyTestClass
{
} //MyTestClass

public class MyClass
{
    public static void main(String[]
 args)
    {
        try {
            boolean myBool = false;
            MyTestClass myTestClassInstance = new MyTestClass();

            // Get the type of myTestClassInstance.
            Type myType = myTestClassInstance.GetType();

            // Get the IsPublic property of the myTestClassInstance.
            myBool = myType.get_IsPublic();
            Console.WriteLine("\nIs {0} public? {1}.",
 myType.get_FullName(),
                System.Convert.ToString(myBool));
        }
        catch (System.Exception e) {
            Console.WriteLine("\nAn exception occurred: {0}", e.get_Message());
        }
    } //main
} //MyClass

入れ子になったクラス場合は、IsPublic および IsNotPublic結果無視しIsNestedPublic および IsNestedPrivate の結果だけに注目してください

プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照

_Type.IsPublic プロパティ

メモ : このプロパティは、.NET Framework version 2.0新しく追加されたものです。

COM オブジェクトに、Type.IsPublic プロパティへのバージョン依存しないアクセス用意されています。

このプロパティは、CLS準拠していません。  

名前空間: System.Runtime.InteropServices
アセンブリ: mscorlib (mscorlib.dll 内)
構文構文

bool IsPublic { get; }
property bool IsPublic {
    bool get ();
}
/** @property */
boolean get_IsPublic ()

プロパティ
最上位Typeパブリックとして宣言されている場合trueそれ以外場合false

解説解説
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照



英和和英テキスト翻訳>> Weblio翻訳
英語⇒日本語日本語⇒英語
  

辞書ショートカット

すべての辞書の索引

「Type.IsPublic プロパティ」の関連用語

Type.IsPublic プロパティのお隣キーワード
検索ランキング

   

英語⇒日本語
日本語⇒英語
   



Type.IsPublic プロパティのページの著作権
Weblio 辞書 情報提供元は 参加元一覧 にて確認できます。

   
日本マイクロソフト株式会社日本マイクロソフト株式会社
© 2024 Microsoft.All rights reserved.

©2024 GRAS Group, Inc.RSS