62,047
社区成员
发帖
与我相关
我的任务
分享
static void Main(string[] args)
{
string[] temp={"999|aa","","","88|bb","77|ee"};
for(int i=0;i<temp.Length;i++)
{
if (temp[i] != "")
{
string str = temp[i].Split('|')[0];
Console.Write(str+" ");
}
}
}
void Main()
{
//linq
double[] Temp_=new double[]{999,233,100,23.5,342,9854,3.5};
Console.WriteLine("排序前:****************");
Temp_.ToList().ForEach(t=>Console.WriteLine(t));
Console.WriteLine("排序后:****************");
Temp_=Temp_.OrderByDescending(t=>t).ToArray();
Temp_.ToList().ForEach(t=>Console.WriteLine(t));
/*
排序前:****************
999
233
100
23.5
342
9854
3.5
排序后:****************
9854
999
342
233
100
23.5
3.5
*/
}
double[] Temp_ = new double[] { 999, 233, 100, 23.5, 342, 9854, 3.5 };
//降序排
Array.Sort<double>(Temp_, (d1, d2) => d2.CompareTo(d1));
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
double[] Temp = { 999, 233, 100, 23.5, 342, 9854, 3.5 };
for (int i = 0; i < Temp.Length; i++)
{
for (int j = i; j < Temp.Length; j++)
{
if (Temp[i] < Temp[j])
{
double temp = Temp[i];
Temp[i] = Temp[j];
Temp[j] = temp;
}
}
Console.Write(Temp[i]+" ");
}
}
}
}