0

Ask the user to input the parameters

I have declared a two dimensional array [199,7] then I declared a method for this array which stores a string data in this array, 'Method(string1,....,string6). Now I want to declare my method inside the Main and ask the user to input it's parameters How do I exactly do that?

21st Jun 2022, 2:40 PM
Bassel Alhasan
Bassel Alhasan - avatar
1 ответ
0
If this is on Sololearn, you will need to ask for the input all at the same time. One way to do so is just by having different variables that will store the input, and then pass those same variables through the parameters for the function declared in main. For example: input1 = input () input2 = input () input3 = input () input4 = input () input5 = input () input6 = input () Method(input1, input2, input3, input4, input5, input6) It's not the best way becauss it doesn't adhere to DRY principles but Sololearn does not allow input to be take more than once, so this is a workaround. If you are doing so in a proper IDE, you can ask them to use the command line and have their input at arguments and then store those in the method. For example: int main(int argc, char *argv) { //Make conditions to make sure the user put in the right amount of arguments //Pass the arguments through the method in some way, I'm not exactly sure how in C# though Method(argv[1], argv[2], argv[3], argv[4], argv[5], etc) }
21st Jun 2022, 2:52 PM
Justice
Justice - avatar