İngilizce dilinde oku

Aracılığıyla paylaş


Type.IsPublic Özellik

Tanım

öğesinin genel olarak bildirilip bildirildiğini Type belirten bir değer alır.

C#
public bool IsPublic { get; }

Özellik Değeri

true Type genel olarak bildirilirse ve iç içe bir tür değilse; aksi takdirde , false.

Uygulamalar

Örnekler

Aşağıdaki örnek, bir örneğini MyTestClassoluşturur, özelliğini denetler IsPublic ve sonucu görüntüler.

C#
using System;

public class TestClass
{
}

public class Example
{
   public static void Main()
   {
      TestClass testClassInstance = new TestClass();
      // Get the type of myTestClassInstance.
      Type   testType = testClassInstance.GetType();
      // Get the IsPublic property of testClassInstance.
      bool isPublic = testType.IsPublic;
      Console.WriteLine("Is {0} public? {1}", testType.FullName, isPublic);
   }
}
// The example displays the following output:
//        Is TestClass public? True

İç içe sınıflar için ve IsNotPublic sonuçlarını yoksayın IsPublic ve yalnızca ve IsNestedPrivatesonuçlarına IsNestedPublic dikkat edin.

Açıklamalar

İç içe türler ile kullanmayın; yerine kullanın IsNestedPublic .

Geçerli Type , genel türdeki bir tür parametresini temsil ederse, bu özellik döndürür true.

TypeAttributes.VisibilityMask görünürlük özniteliklerini seçer.

Şunlara uygulanır

Ürün Sürümler
.NET Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9, 10
.NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 2.0, 2.1

Ayrıca bkz.