Reputation: 103
I am attempting to complete leetcode's problem #1266 (https://leetcode.com/problems/minimum-time-visiting-all-points/).
My solution works on Visual Studio just fine, but when I submit it to leetcode I encounter a compile time error :
Line 19: Char 12: error CS8320: Feature 'tuple equality' is not available in C# 7.2. Please use language version 7.3 or greater. (in Solution.cs)
(int, int) current = test[0];
(int, int) target = test.Last();
for (int i = 1; i < test.Count; i++)
{
target = test[i];
while (current != target) <<<<<<<<<<<<< ERROR LINE according to leetcode
I believe my VS2019 was up to date to begin with (I am now updating to the latest build : 16.3.9 --> 16.4.0
) so I'm not sure what else I need to do on my end.
My question is : is there a simple alternative I could use or should I just move on? (As far as I'm concerned my solution passes - it completed the given test cases.)
Thanks for any time and help.
P.S. Sorry if you need more of my code, I'll include it if asked for. It's rather hacky and long, haha.
Upvotes: 2
Views: 72
Reputation: 186688
Instead of comparing tuples, you can compare tuples' properties:
...
// tuples current and target are not equal if either Item1 or Item2 are not equal
while (current.Item1 != target.Item1 || current.Item2 != target.Item2)
...
You may want explicit Tuple<int, int>
syntax as well:
Tuple<int, int> current = test[0];
Tuple<int, int> target = test.Last();
Upvotes: 3