📄 ex-09-01
字号:
//Example 09-01: Working with an array
namespace Programming_CSharp
{
using System;
// a simple class to store in the array
public class Employee
{
// a simple class to store in the array
public Employee(int empID)
{
this.empID = empID;
}
public override string ToString()
{
return empID.ToString();
}
private int empID;
private int size;
}
public class Tester
{
static void Main()
{
int[] intArray;
Employee[] empArray;
intArray = new int[5];
empArray = new Employee[3];
// populate the array
for (int i = 0;i<empArray.Length;i++)
{
empArray[i] = new Employee(i+5);
}
for (int i = 0;i<intArray.Length;i++)
{
Console.WriteLine(intArray[i].ToString());
}
for (int i = 0;i<empArray.Length;i++)
{
Console.WriteLine(empArray[i].ToString());
}
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -