namespace ConsoleApp231
{
internal class Program
{
public static void exerciseAdd()
{
Console.Write("姓名"+"\t性别"+"\t出生日期");
Console.WriteLine();
string[] arr=new string[] {"小王","男","1980-01-01","小刘","男","1981-01-01","小明","男","1990-01-01"};
ArrayList studentInfo = new ArrayList(arr);
for (int i=0; i<arr.Length;i++)
{
Console.Write(studentInfo[i] + "\t");
if ((i+1)!=0 && (i + 1) % 3 == 0)
{
string.Format("{0:D}", Convert.ToDateTime(studentInfo[i]));
Console.WriteLine();
}
}
}
static void Main(string[] args)
{
Program.exerciseAdd();
Console.ReadLine();
}
}
}
最后输出:
姓名 性别 出生日期
小王 男 1980-01-01
小刘 男 1981-01-01
小明 男 1990-01-01
日期格式仍然无法改变