Type.IsNotPublic Özellik
Tanım
Önemli
Bazı bilgiler ürünün ön sürümüyle ilgilidir ve sürüm öncesinde önemli değişiklikler yapılmış olabilir. Burada verilen bilgilerle ilgili olarak Microsoft açık veya zımni hiçbir garanti vermez.
öğesinin genel olarak bildirilip Type bildirilmediğini belirten bir değer alır.
public:
property bool IsNotPublic { bool get(); };
public bool IsNotPublic { get; }
member this.IsNotPublic : bool
Public ReadOnly Property IsNotPublic As Boolean
Özellik Değeri
true
Type genel olarak bildirilmemişse ve iç içe yerleştirilmiş bir tür değilse, değilse, false.
Uygulamalar
Örnekler
Bu örnekte türün IsNotPublic görünürlüğünü elde etmek için özelliği kullanılır.
using System;
using System.IO;
using System.Reflection;
class Example
{
public static void Main()
{
// Get the Type and MemberInfo.
Type t = Type.GetType("System.IO.File");
MemberInfo[] members = t.GetMembers();
// Get and display the DeclaringType method.
Console.WriteLine("\nThere are {0} members in {1}.",
members.Length, t.FullName);
Console.WriteLine("Is {0} non-public? {1}",
t.FullName, t.IsNotPublic);
}
}
// The example displays output like the following:
// There are 60 members in System.IO.File.
// Is System.IO.File non-public? False
open System
// Get the Type and MemberInfo.
let t = Type.GetType "System.IO.File"
let members = t.GetMembers()
// Get and display the DeclaringType method.
printfn $"\nThere are {members.Length} members in {t.FullName}."
printfn $"Is {t.FullName} non-public? {t.IsNotPublic}"
// The example displays output like the following:
// There are 60 members in System.IO.File.
// Is System.IO.File non-public? False
Imports System.IO
Imports System.Reflection
Module Example
Public Sub Main()
'Get the Type and MemberInfo.
Dim t As Type = Type.GetType("System.IO.File")
Dim members As MemberInfo() = t.GetMembers()
'Get and display the DeclaringType method.
Console.WriteLine("There are {0} members in {1}.",
members.Length, t.FullName)
Console.WriteLine("Is {0} non-public? {1}",
t.FullName, t.IsNotPublic)
End Sub
End Module
' The example displays output like the following:
' There are 60 members in System.IO.File.
' Is System.IO.File non-public? False
Aşağıdaki kod örneği, iç içe sınıflar için ve'yi IsNotPublic neden kullanamayacağınızı IsPublic gösterir.
public class A
{
public class B { }
private class C { }
}
module A =
type B() = class end
type C() = class end
Public Class A
Public Class B
End Class
Private Class C
End Class
End Class
İç 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. Bu kod parçasının yansıma çıkışı aşağıdaki gibi olacaktır:
| Sınıf | IsNotPublic | IsPublic | Isnestedpublic | Isnestedprivate |
|---|---|---|---|---|
| A | YANLIŞ | TRUE | YANLIŞ | YANLIŞ |
| B | YANLIŞ | YANLIŞ | TRUE | YANLIŞ |
| C | YANLIŞ | YANLIŞ | YANLIŞ | TRUE |
Açıklamalar
Bu özelliği iç içe türler ile kullanmayın; IsNestedPublic bunun yerine özelliğini kullanın.
Geçerli Type , genel türdeki bir tür parametresini temsil ederse, bu özellik döndürür false.