Check out example codes for "in another method display sum of elements in different arrays in c#". It will help you in understanding the concepts better.

Code Example 1

using System;
public class funcexer5
    public static int Sum(int[] arr1)
        int tot=0;
        for (int i = 0;i < arr1.Length; i++)
        tot += arr1[i];
        return tot;
    public static void Main()
       int[] arr1 = [5, 5, 6, 4];
       Console.Write("\n\nFunction : Calculate the sum of the elements in an array :\n");  
       Console.WriteLine("The sum of the elements of the array is {0}", Sum(arr1));

Learn ReactJs, React Native from