小编Chr*_*yer的帖子

我在哪里可以在我的c#程序中使用全局变量?

我的导师为我设定了制作C#程序的任务

  • 演示递归(我想我已经做到了)
  • 使用全局变量
  • 可以被企业使用

这就是我想出来的.它只需要是一个小程序,但我不知道在哪里可以使用全局变量.我在考虑减税,但每次开始我都会忘记我的想法.

static void nameCheck()
{
    Console.WriteLine("Name of employee: ");
    string employee = Console.ReadLine();

    string[] employees = { "Emp1", "Emp2", "Emp3", "Emp4" };

    File.WriteAllLines("C:/Users/Chris/Documents/Visual Studio 2013/Projects/ConsoleApplication38/Employees.txt", employees);

    string[] lines = File.ReadAllLines("C:/Users/Chris/Documents/Visual Studio 2013/Projects/ConsoleApplication38/Employees.txt");

    int match = 0;
    foreach (string line in lines)
    {
        if (employee != line)
        {
            match = match + 1;
            if (match > 3)
            {
                Console.WriteLine("That name is not in the employee database, try again:");
                nameCheck();
            }
        }
    }
}
static double payRoll(double hours, …
Run Code Online (Sandbox Code Playgroud)

.net c# global-variables

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

标签 统计

.net ×1

c# ×1

global-variables ×1