c#中逆转数组元素的排序实例代码如下:
private string[] G_str_array;//定义字符串数组字段
private void Frm_Main_Load(object sender, EventArgs e)
{
G_str_array = new string[] {"C#-1","C#-2","C#-3","C#-4","C#-5"};//为字符串数组字段赋值
foreach (string str in G_str_array)//遍历字符串数组集合codego.net
{
lab_str.Text += str + Environment.NewLine;//显示字符串数组
}
}
private void btn_Reverse_Click(object sender, EventArgs e)
{
lab_str2.Text = string.Empty;//清空信息
foreach (string str in G_str_array.Reverse())//遍历反转后的字符串数组
{
lab_str2.Text += str + Environment.NewLine;//显示字符串数组
}
}
时间: 2024-10-13 02:29:57