本文整理匯總了VB.NET中System.Reflection.PropertyInfo.GetIndexParameters方法的典型用法代碼示例。如果您正苦於以下問題:VB.NET PropertyInfo.GetIndexParameters方法的具體用法?VB.NET PropertyInfo.GetIndexParameters怎麽用?VB.NET PropertyInfo.GetIndexParameters使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類System.Reflection.PropertyInfo
的用法示例。
在下文中一共展示了PropertyInfo.GetIndexParameters方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的VB.NET代碼示例。
示例1: MyProperty
' 導入命名空間
Imports System.Reflection
Imports System.Collections
' A test class that has some properties.
Public Class MyProperty
' Define a simple string property.
Private myCaption As String = "A Default caption"
Public Property Caption() As String
Get
Return myCaption
End Get
Set(ByVal Value As String)
If myCaption <> value Then
myCaption = value
End If
End Set
End Property
' A very limited indexed default property that gets or
' sets one of four string values.
Private strings() As String = {"abc", "def", "ghi", "jkl"}
Public Default Property Item(ByVal Index As Integer) As String
Get
Return strings(Index)
End Get
Set
strings(Index) = Value
End Set
End Property
End Class
Public Class Example
Public Shared Function Main() As Integer
' Get the type and PropertyInfo.
Dim t As Type = GetType(MyProperty)
Dim pi As PropertyInfo = t.GetProperty("Caption")
' Get an array containing the parameters (if any).
Dim params As ParameterInfo() = pi.GetIndexParameters()
Console.WriteLine(vbCrLf & t.FullName & "." & pi.Name & _
" has " & params.GetLength(0) & " parameters.")
' Display a property that has parameters.
pi = t.GetProperty("Item")
params = pi.GetIndexParameters()
Console.WriteLine(t.FullName & "." & pi.Name & _
" has " & params.GetLength(0) & " parameters.")
For Each p As ParameterInfo In params
Console.WriteLine(" Parameter: " & p.Name)
Next
Return 0
End Function
End Class
輸出:
MyProperty.Caption has 0 parameters. MyProperty.Item has 1 parameters. Parameter: Index