我已经google了一下,但仍然没有找到我正在寻找的东西。我想要发生的是我希望应用程序自动获取日期和时间,因此您不必手动输入。
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace RegisterApp
{
class TimeRegister
{
static void Register(string[] args)
{
Console.WriteLine("Time of Arrival Program!");
Console.ReadLine();
string[] EmployeeName = new string[5];
string TimeofArr;
int i;
for (i = 0; i < 5; ++i)
{
Console.WriteLine("Welcome, Kindly enter your Name: ");
EmployeeName[i] = Console.ReadLine();
string TimeofArr = DateTime.Now.ToString();
Console.WriteLine(TimeofArr);
Console.ReadLine();
}
}
}
}
有没有SIMPLE可以解决的问题,我说这很简单,因为我是c#的新手,并且不了解所有的概念/术语。感谢。
答案 0 :(得分:1)
阅读你的上一条评论我得出结论你只需要让ReadLine
脱离循环:
for (i = 0; i < 5; ++i)
{
Console.WriteLine("Welcome, Kindly enter your Name: ");
EmployeeName[i] = Console.ReadLine();
string TimeofArr = DateTime.Now.ToString();
Console.WriteLine(TimeofArr);
}
Console.ReadLine();
答案 1 :(得分:0)
到Console.ReadLine();
停止等待您输入
答案 2 :(得分:0)
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace RegisterApp
{
class TimeRegister
{
static void Register(string[] args)
{
Console.WriteLine("Time of Arrival Program!");
Console.ReadLine();
string[] EmployeeName = new string[5];
for (int i = 0; i < 5; ++i)
{
Console.WriteLine("Welcome, Kindly enter your Name: ");
EmployeeName[i] = Console.ReadLine();
Console.WriteLine(DateTime.Now.ToString());
}
}
}
}