Creating Main Class
Our Main class will have an array and variable sum as value number. We also need call function countTriplets to counting our answer. You can custom the value of array and sum whatever you want.
public static void Main()
{
int[] arr = new int[] { 5, 1, 3, 4, 7 };
int sum = 12;
Console.WriteLine(countTriplets(arr, arr.Length, sum));
}
countTriplets function need three parameters, the array, array length (just for sake of convenience), and sum value.