-1
\$\begingroup\$

Without changing the actual function, call it in such a way that it prints "True"

void Puzzle(out int x, out int y)
{
  x = 0;
  y = 1;
  Console.WriteLine(x == y);
}

Online Tester

\$\endgroup\$
1
  • 2
    \$\begingroup\$ Programming puzzle challenges should usually include some indication how the "best" answer is chosen is several valid solutions are posted. \$\endgroup\$ Commented Mar 17, 2015 at 9:08

2 Answers 2

5
\$\begingroup\$

Reusing reference:

//C# Puzzle: Call the Puzzle() function in Main such that it prints True. 
//You have to do this without changing the Puzzle method.

public void Main()
{
  int x,y;
  Puzzle(out x, out x);
}

void Puzzle(out int x, out int y)
{
    x = 0;
    y = 1;
    Console.WriteLine (x == y);
}
\$\endgroup\$
4
\$\begingroup\$

Solved!

Puzzle(out x, out x);

http://volatileread.com/utilitylibrary/snippetcompiler?id=9697

\$\endgroup\$

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.