C#语言输入10个职工姓名和职工号
时间: 2023-10-08 17:05:27 浏览: 35
你想要一个控制台程序吗?如果是的话,可以使用以下代码:
```
using System;
namespace EmployeeInfo
{
class Program
{
static void Main(string[] args)
{
string[] names = new string[10];
int[] ids = new int[10];
for (int i = 0; i < 10; i++)
{
Console.Write("Enter name of employee {0}: ", i + 1);
names[i] = Console.ReadLine();
Console.Write("Enter ID of employee {0}: ", i + 1);
ids[i] = Convert.ToInt32(Console.ReadLine());
}
Console.WriteLine("Employee Information:");
for (int i = 0; i < 10; i++)
{
Console.WriteLine("Name: {0}, ID: {1}", names[i], ids[i]);
}
Console.ReadLine();
}
}
}
```
在这个程序中,我们定义了一个字符串数组 `names` 和一个整数数组 `ids` 来存储职工的姓名和职工号。然后,我们使用一个 `for` 循环来让用户输入每个职工的信息。最后,我们使用另一个 `for` 循环来显示所有职工的信息。