2

私は次のものを持っています。myExampleクラスをクエリして、クラスのメソッド名の配列を返すにはどうすればよいですか?

Sub Main()
    Dim x As New myExample

    '<<would like to return an array of x's method names i.e. {"hello","world","foo","bar"}

    Console.WriteLine("press [enter] to exit")
    Console.Read()
End Sub

Class myExample

    Public Shared y As Integer

    Public Sub hello()
        y = 1
    End Sub
    Public Sub world()
        y = 2
    End Sub
    Public Sub foo()
        y = 3
    End Sub
    Public Sub bar()
        y = 4
    End Sub
End Class
4

1 に答える 1

2

すべてのメソッド (継承を含む):

Dim example As New myExample()
Dim t As Type = example.GetType()
Dim methods = t.GetMethods()
Dim allMethodNames() As String = methods.Select(Function(m) m.Name).ToArray()

Type.GetMethods

于 2013-01-24T08:57:08.763 に答える