Skip to content

Instantly share code, notes, and snippets.

@gaufung
Created September 13, 2020 07:51
Show Gist options
  • Select an option

  • Save gaufung/803d6675be9515aeba9175ed81b00012 to your computer and use it in GitHub Desktop.

Select an option

Save gaufung/803d6675be9515aeba9175ed81b00012 to your computer and use it in GitHub Desktop.
Calculator prototype
// program.cs
static void Main(string[] args)
{
const string WELCOME = "Welcome to Calculator. Feel free to type any expression you want.";
const string PROMPT = ">> ";
Console.Out.Write(WELCOME + Environment.NewLine);
while(true)
{
Console.Out.Write(PROMPT);
try
{
var input = Console.In.ReadLine();
if(string.Compare(input, "exit", StringComparison.OrdinalIgnoreCase) == 0)
{
break;
}
Console.Out.Write(input);
Console.Out.Write(Environment.NewLine);
}
catch(Exception e)
{
Console.Out.Write("Oops! Something seems to go wrong." + Environment.NewLine);
Console.Out.Write(e.Message);
Console.Out.Write(Environment.NewLine);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment