[Solved] how to return value as array object [closed]


Hope that you can try like this:

return a.GroupBy(v => v).Select(x=> x.Key + x.Count()).ToArray();

If you are expecting sum of each key and count of elements associated with that keys in the result array. Please Go through this example, and let me know your result is different than this:

The method signature will be changed as like this:

public static int[] twodigi(int number)
{
    Random random = new Random();    
    int[] a = new int[number];
    for (int i = 0; i < number; i++)
    {         
        a[i] = random.Next(10, 100);
    }

      return a.GroupBy(v => v).Select(x=> x.Key + x.Count()).ToArray();
}

1

solved how to return value as array object [closed]