I am Developing an windows Application, oftentimes I need to clear the Textboxes whenever the user save the Record or click on clear button. Currently i am using this code txtboxname.text=string.empty; for each textbox
So can it be possible to write a method that accept the n number of parameter like reading the all the Textboxes in an array and using foreach we can clear them
the main requirement is to write a method which accept the n number of parameter i.e The parameter size will be unknown.
If any body having idea about how to do this then please help me. Thanks in Advance.
Out Parameters. Default Parameters or Optional Arguments (C# 4.0 and above) Dynamic parameter (dynamic keyword). Value parameter or Passing Value Types by Value (normal C# method param are value parameter)
Named parameters provides us the relaxation to remember or to look up the order of parameters in the parameter lists of called methods. The parameter for each argument can be specified by parameter name. Using named parameters in C#, we can put any parameter in any sequence as long as the name is there.
With the params
keyword.
Here is an example:
public void MyMethod(params int[] numbers) { for (int i = 0; i < numbers.Length; i++) { //numbers[i] is one of the parameters } }
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With