小编un *_*own的帖子

在C#'switch'语句中更改变量

对于学校作业,我应该创建一个类似ATM的菜单.

我的教授给了我们这段代码:

string choice = null;

do
{
    Console.Write("[O]pen Account [I]nquire [D]eposit [W]ithdraw [Q]uit: ");
    choice = Console.ReadLine();
    choice = choice.ToUpper();

    switch (choice)
    {
        case "O": // open an account
        case "I": // inquire
        case "D": // deposit
        case "W": // withdraw
        default: break;
    }
} while (choice != "Q");
Run Code Online (Sandbox Code Playgroud)

这是我做的:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            string choice = null;
            string CustomerName;

            Console.WriteLine("Welcome to …
Run Code Online (Sandbox Code Playgroud)

c# switch-statement visual-studio

3
推荐指数
1
解决办法
568
查看次数

标签 统计

c# ×1

switch-statement ×1

visual-studio ×1