本文整理匯總了VB.NET中System.Reflection.FieldInfo.IsPublic屬性的典型用法代碼示例。如果您正苦於以下問題:VB.NET FieldInfo.IsPublic屬性的具體用法?VB.NET FieldInfo.IsPublic怎麽用?VB.NET FieldInfo.IsPublic使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在類System.Reflection.FieldInfo
的用法示例。
在下文中一共展示了FieldInfo.IsPublic屬性的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的VB.NET代碼示例。
示例1: Myfielda
' 導入命名空間
Imports System.Reflection
' Make two fields.
Public Class Myfielda
' Make a private field.
Private SomeField As String = "private field"
Public ReadOnly Property Field() As String
Get
Return SomeField
End Get
End Property
End Class
Public Class Myfieldb
' Make a public field.
Public SomeField As String = "public field"
End Class
Public Class Myfieldinfo
Public Shared Function Main() As Integer
Console.WriteLine("Reflection.FieldInfo")
Console.WriteLine()
Dim Myfielda As New Myfielda()
Dim Myfieldb As New Myfieldb()
' Get the Type and FieldInfo.
Dim MyTypea As Type = GetType(Myfielda)
Dim Myfieldinfoa As FieldInfo = MyTypea.GetField("SomeField", _
BindingFlags.NonPublic Or BindingFlags.Instance)
Dim MyTypeb As Type = GetType(Myfieldb)
Dim Myfieldinfob As FieldInfo = MyTypeb.GetField("SomeField")
' Get and display the IsPublic and IsPrivate property values.
Console.WriteLine("{0}.{1} - {2}", MyTypea.FullName, Myfieldinfoa.Name, _
Myfielda.Field)
Console.WriteLine(" IsPublic = {0}", Myfieldinfoa.IsPublic)
Console.WriteLine(" IsPrivate = {0}", Myfieldinfoa.IsPrivate)
Console.WriteLine()
Console.WriteLine("{0}.{1} - {2}", MyTypeb.FullName, Myfieldinfob.Name, _
Myfieldb.SomeField)
Console.WriteLine(" IsPublic = {0}", Myfieldinfob.IsPublic)
Console.WriteLine(" IsPrivate = {0}", Myfieldinfob.IsPrivate)
Return 0
End Function 'Main
End Class