Invoke Methods

On the Workbench window, right-click on the instance on which to execute a method, and select the Invoke context menu option.


Choose Method

A list of methods for the type are presented in a dialog. Select a method from the list and click on the Invoke button. Note that all methods listed are public; private methods are not available.


Supply Arguments

In this example, you have created an instance or variable named Rob of type MyClassLibrary.CRobert, and have invoked a method named AddFriends that takes an array of CPerson objects as its only argument. What you now supply to it are the three other Workbench instances Fred, John and William.



In the dialog above, type any parameters required by the constructor.

  • Literals as arguments
  • Text:        abc or "abc" or "a b c"
  • Numbers:        1 or 1.5
  • Objects as arguments

       If an argument is not a literal then you can supply it in the list only if you have already created an instance of that type in the workbench. You do this by typing the name of the instance as the argument. The debugger checks any name entered in an argument against its list of workbench instances, and substitutes that instance in the actual call to the method.

  • Strings as arguments

       Surrounding strings with quotes is unnecessary as anything you type for a string argument becomes the value of the string; for example, the only time you should surround strings with quotes is in supplying elements of a string array, or where the string is equal to the name of an existing workbench instance.

               "A b c"

               "a b $ % 6 4"

               A b c d

               As 5 7 ) 2 === 4

  • Arrays as arguments

       Enter the elements that compose the array, separated by commas.

               Type                Arguments

               String[]                one,two,three,"a book","a bigger book"

               CPerson[]        Tom,Dick,Harry


If you enter text that matches the name of an existing instance, surround it in quotes to avoid the debugger passing the instance rather than a string.



Having chosen the constructor and supplied any arguments, click on the Invoke button to create the variable. Output confirming this action is displayed in the Output tab.