C#
Code
# Code
```csharp []
public class Solution {
        public long MaximumValueSum(int[] nums, int k, int[][] edges)
  {
      long[][] memo = new long[nums.Length][];
      for (int i = 0; i < nums.Length; i++)
      {
          memo[i] = new long[] {-1, -1, -1};
        //  Array.Fill(memo[i], -1);
          
      }
      return MaxSumOfNodes(0, 1, nums, k, memo);
  }

  private long MaxSumOfNodes(int index, int isEven, int[] nums, int k,
          long[][] memo)
  {
      if (index == nums.Length)
      {
          // If the operation is performed on an odd number of elements, return
          // int.MinValue
          return isEven == 1 ? 0 : int.MinValue;
      }
      if (memo[index][isEven] != -1)
      {
          return memo[index][isEven];
      }
      // No operation performed on the element
      long noXorDone = nums[index] + MaxSumOfNodes(index + 1, isEven, nums, k, memo);
      // XOR operation is performed on the element
      long xorDone = (nums[index] ^ k) +
              MaxSumOfNodes(index + 1, isEven ^ 1, nums, k, memo);

      // Memoize and return the result
      return memo[index][isEven] = Math.Max(xorDone, noXorDone);
  }
    
}
```
['C#']