c# - How to take the Product of a List? -


i trying make factorial calculator in c#, having difficulties taking product of numbers after have collected them list.

        list<int> mylist = new list<int>();          console.writeline("my job take factorial of number give");         console.writeline("what number?");         string = console.readline();         int c = convert.toint32(a);         t:         mylist.add(c);         c--;          if (c == 0) goto end;         goto t;     end:         // problem is,         // don't know of way take product of list "mylist"         //any ideas?         int total = mylist.product();         console.writeline(" = {0}", total);         console.readline(); 

you don't need list factorial:

console.writeline("my job take factorial of number give"); console.writeline("what number?"); int c = convert.toint32(console.readline()); int total = 1;  (int = 2; < c; i++) {     total *= i; }  console.writeline(total.tostring()); console.readline(); 

Comments