本文整理汇总了C#中Counter.AddOne方法的典型用法代码示例。如果您正苦于以下问题:C# Counter.AddOne方法的具体用法?C# Counter.AddOne怎么用?C# Counter.AddOne使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Counter
的用法示例。
在下文中一共展示了Counter.AddOne方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Main
static void Main()
{
Intro();
Counter userCounter = new Counter();
bool exit = false;
bool first = true;
do
{
if (first)
{
Help();
first = false;
}
Console.Write("What would you like to do? (Enter 0 for options) : ");
int input;
bool validate = int.TryParse(Console.ReadLine(), out input);
if (validate)
{
switch (input)
{
case 0:
Help();
break;
case 1:
userCounter.AddOne();
Console.WriteLine("Counter increased by 1...");
break;
case 2:
userCounter.SubtractOne();
Console.WriteLine("Counter decreased by 1...");
break;
case 3:
Console.WriteLine("Current count is: " + userCounter.GetValue());
break;
case 4:
userCounter.ResetCounter();
Console.WriteLine("Counter has been reset...");
break;
case 5:
exit = true;
break;
default:
Console.WriteLine("Invalid input, please try again...\n");
break;
}
}
else
{
Console.WriteLine("Invalid input, please try again...\n");
}
} while (!exit);
End();
}