FindIndex() isn't happy with my syntax and I do not know why

Nov 30 2022 7:31 PM

I wrote this code for a leetcode question, I thought i was on the verge of answering it, but cannot get find index to accept my arguements syntax, not only is this what I normally use, it's the only example of the sytax regarding getting index number by an integer item match that I can find.

Problem lines: 

 int index = nums.FindIndex(a => a == temporaryVariableContainer1);
 int otherIndex = nums.FindIndex(b => b == temporaryVariableContainer2);


Full function: 


public int[] TwoSum(int[] nums, int target)
    {
        int currentIndex = 0;
        int[] answer;

        int indexIncrementer = 1;
        int temporaryVariableContainer1 = nums[currentIndex]; ;
        int temporaryVariableContainer2 = nums[currentIndex + indexIncrementer];

        while (target != temporaryVariableContainer1 + temporaryVariableContainer2)
        {
            temporaryVariableContainer1 = nums[currentIndex];
            temporaryVariableContainer2 = nums[currentIndex + indexIncrementer];

            if (indexIncrementer == nums.Length)
            {
                indexIncrementer = 1;
                currentIndex++;
            }
            else if (indexIncrementer < nums.Length)
            {
                indexIncrementer++;
            }
            else
            {
                int index = nums.FindIndex(a => a == temporaryVariableContainer1);
                int otherIndex = nums.FindIndex(b => b == temporaryVariableContainer2);
            }

        }
    
        answer = new int[] { temporaryVariableContainer1, temporaryVariableContainer2};
        return answer;
    }

The error I get on lines 26 and 27 of the above code are 

No overload for method 'method' takes 'number' arguments

A call was made to a class method, but no definition of the method takes the specified number of arguments.

Heres the main method incase that helps
 

 static void Main(string[] args)
    {
        Solution solution = new Solution();
        int[] nums = new int[] { 2, 7, 11, 15 };
        solution.TwoSum(nums, 9);
    }


 


Answers (1)