That isn't all your code: that code on it's own generates no errors, and runs, doing what you expected it to:
public class Program
public static void Main()
Somewhere else in the same scope in your code, you are declaring something called "ans" - a variable, constant, or even a method!
And don't use Convert methods on user input - they will cause you app to crash if the user enters a non-numeric character. Use the TryParse methods instead: Int32.TryParse Method (System) | Microsoft Docs
]. They return a bool "OK / Failed" result so you can give them another chane.