0
If I add "public" while defining a variable in main method it shows me error in c#,why?
here is the code class Program { static void Main(string[] args) { public string yourName; Console.WriteLine("What is your name?"); yourName = Console.ReadLine(); Console.WriteLine("Hello {0}", yourName); } }
1 Resposta
+ 1
access delimiters like public or private only has sense when declearing them in a class, NOT in a method inside the class. You should rewrite that line before or after the Main method, but inside the class.