1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53
| Module Module1
Function function1(ByVal param1 As String, ByVal param2 As String) As Boolean
Dim hash As Hashtable = New Hashtable
Dim stFrame As New StackFrame
Dim currentMethod As System.Reflection.MethodBase = stFrame.GetMethod()
Dim currentParameters() As System.Reflection.ParameterInfo = currentMethod.GetParameters()
For Each param As System.Reflection.ParameterInfo In currentParameters
hash.Add(param.Name, "valeur of param ?") 'Comment spécifier la valeur résultante ?)
Next
display(currentMethod.Name, hash)
Return True
End Function
Function function1(ByVal param1 As String, ByVal param2 As String, ByVal param3 As String) As Boolean
Dim hash As Hashtable = New Hashtable
Dim stFrame As New StackFrame
Dim currentMethod As System.Reflection.MethodBase = stFrame.GetMethod()
Dim currentParameters() As System.Reflection.ParameterInfo = currentMethod.GetParameters()
For Each param As System.Reflection.ParameterInfo In currentParameters
hash.Add(param.Name, "valeur of param ?") 'Comment spécifier la valeur résultante ?)
Next
display(currentMethod.Name, hash)
Return True
End Function
Function function2(ByVal param1 As String, ByVal param2 As String) As Boolean
Dim hash As Hashtable = New Hashtable
Dim stFrame As New StackFrame
Dim currentMethod As System.Reflection.MethodBase = stFrame.GetMethod()
Dim currentParameters() As System.Reflection.ParameterInfo = currentMethod.GetParameters()
For Each param As System.Reflection.ParameterInfo In currentParameters
hash.Add(param.Name, "valeur of param ?") 'Comment spécifier la valeur résultante ?)
Next
display(currentMethod.Name, hash)
Return True
End Function
Sub display(ByVal nomfunction As String, ByVal hashtable As Hashtable)
Console.WriteLine(String.Format("Nom de la fonction:" & nomfunction))
For Each AttributeName As String In hashtable.Keys
Console.WriteLine(String.Format(" Nom du param:{0} , valeur:{1}", AttributeName, hashtable(AttributeName)))
Next
End Sub
Sub Main()
Dim res As Boolean
res = function1("Param1WithFn1", "Param2WithFn1")
res = function1("Param1WithFn1", "Param2WithFn1", "Param3WithFn1")
res = function2("Param1WithFn2", "Param2WithFn2")
End Sub
End Module |
Partager