Pagsasanay
Module
Create C# methods with parameters - Training
This module covers method parameters, including pass-by-reference and pass-by-value parameter types. This module also covers optional and named arguments.
Hindi na suportado ang browser na ito.
Mag-upgrade sa Microsoft Edge para samantalahin ang mga pinakabagong tampok, update sa seguridad, at teknikal na suporta.
What: Lets you modify a function's parameters.
When: You want to reorder, add, remove, or modify a function's parameters that are used in various locations.
Why: You could manually change these parameters yourself, and then find all calls to that function and change them one-by-one, but that could lead to errors. This refactoring tool will perform the task automatically.
How:
Place the text or mouse cursor inside the name of the method to modify, or one of its usages:
Next, do one of the following:
In the Change Signature dialog that pops up, you can use the buttons on the right side to change the method signature:
Button | Description |
---|---|
Up/Down | Move the selected parameter up and down the list |
Add | Add a new parameter to the list |
Remove | Remove the selected parameter from the list |
Modify | Modify the selected parameter by changing its type, name, and whether it's optional, and what its injected value would be |
Revert | Restore the selected parameter its original state |
Revert All | Restore all parameters to their original state |
Tip
Use the Skip preview reference changes if all references are confirmed checkbox to make the changes immediately without the preview window popping up first.
When adding or modifying a parameter, you'll see the Add Parameter or Edit Parameter window.
Here, you can do the following:
Entry | Description |
---|---|
Type | The type of the parameter (int, double, float, etc.) |
Name | The name of the parameter |
Optional Parameter | Make the parameter optionally specified |
Injected Value | The value inserted into any calls to the function where the parameter isn't specified (only valid for Add) |
Default value | The value used by the function if the caller doesn't specify one (only valid for Optional Parameters) |
Use the Search scope drop-down to select if the changes will apply to the project or the entire solution.
When you're finished, press the OK button to make the changes. Ensure that the changes you're requesting are being made appropriately. Use the checkboxes in the top half of the window to enable or disable the renaming of any item.
When everything looks good, click the Apply button, and the function will be changed in your source code.
Pagsasanay
Module
Create C# methods with parameters - Training
This module covers method parameters, including pass-by-reference and pass-by-value parameter types. This module also covers optional and named arguments.
Dokumentasyon
Create Declaration / Definition
Learn more about: Create Declaration / Definition
Learn more about: Rename
Learn more about: Move Definition Location