0

I got some errors

this is code to caliculate permutation, combination and factorial. only caliculation of factorial puts out errors. how can i solve this? https://code.sololearn.com/c6o5z9mFE829/?ref=app

31st Mar 2019, 10:19 AM
rym
rym - avatar
2 Antworten
0
You have an error in line 40. If you want to use 'Select' method you must provide appropriate selector function (in your case it will be a method which takes string as an argument and returns int). You can write this as lambda expression: s => int.Parse(s). Another problem is that after splitting a string with '!' at the end of the string you will get an array with 2 elements (the last element is an empty string) so you should do some additional check to avoid parsing errors (for example if string is not empty). line 40: static int[] nums = strnums.Where(s => s != string.Empty).Select(s => int.Parse(s)).ToArray();
31st Mar 2019, 11:31 AM
gambler
0
code worked correctly. actually i used Select method by c&p. but thank to your answer i understood system of the method. thank you so much!
1st Apr 2019, 10:45 AM
rym
rym - avatar