I asked the following question: # and the user @bigown answered me, however, in the answer he used an operator and this gave me a new question. I questioned the same about the use of the operator and he indicated to me the following link for clarification: What is the purpose of the operator = > not using lists? . However, it is still unclear to me.
What are the benefits of using the =>
operator in methods that are not related to lists or lambda expressions?
If the operator has no relation to lists or lambda expression. How would the operation be called if it is not or is not related to an anonymous function?
I tried to run the following code in ConsoleApplication, however, from the operator declaration error = > saying that the ";" is expected. If this operator has this function should not present such error.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication1
{
public class C
{
public int Main() {
var conta = new Conta();
var txtValor = new Form();
bool retorno;
if ((retorno = conta.Saca(Convert.ToDouble(txtValor.Text)))) {
Console.WriteLine(retorno);
return 1;
}
return 0;
}
}
public class Conta {
public bool Saca(double x) => true;
}
public class Form {
public String Text;
}
}