public IActionResult Arrays([FromBody] ArraysClass Array) { int result = 0; if (Array.What == "sum") { for (int i = 0; i < Array.Numbers.Length; i++) { result += Array.Numbers[i]; } return(new JsonResult(new { result })); } if (Array.What == "multiply") { result = 1; for (int i = 0; i < Array.Numbers.Length; i++) { result *= Array.Numbers[i]; } return(new JsonResult(new { result })); } if (Array.Numbers != null) { if (Array.What == "doubling") { int[] resultArray = new int[Array.Numbers.Length]; for (int i = 0; i < Array.Numbers.Length; i++) { resultArray[i] = Array.Numbers[i] * 2; } return(new JsonResult(new { resultArray })); } } return(new JsonResult(new { error = "Please provide what to do with the numbers!" })); }
public void TestInitialise() { Debug.Write("Test initialize"); array = new ArraysClass(sizeFirst, sizeSecond); }