I’m writing a code to revere a word in sentence but getting build error of CS0136: A local or parameter name
“input” can not be declared in this scope because that name is used in an enclosing local scope to define a local or parameter:
string input = "there are snakes at the zoo";
Console.WriteLine(input);
Console.WriteLine(ReverseSentence(input));
string ReverseSentence(string input)
{
string result = "";
char S = ' ';
string[] words = input.Split(S);
foreach (string word in words)
{
result += ReverseWord(word) + " ";
}
return result.Trim();
}
I did not get a proper solution.
New contributor
tanzeel ahmed shaikh is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.