C#排序功能-顺便求最大值

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using System.Data.OleDb;
using Microsoft.Office.Interop.Excel;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            //params 求出最大值

            String s = Console.ReadLine();      //设用户输入6,3,,4,5,6,7,,,8,9,2,19, 23,85, 99,,
            //s = "234,23,5,45,6,5,7,,,8,9,,0,,,5";
            getMax(Processing(s));
        }

        static int[] Processing(string data)
        {

            string[] datas = data.Split(new char[] { ',', ' ' }, StringSplitOptions.RemoveEmptyEntries);
            int[] arr = new int[datas.Length];
            int i = 0;
            foreach (string s in datas)
            {
                arr[i] = Convert.ToInt32(s);
                i++;
            }
            return arr;
        }


        static void getMax(params int[] Datas)
        {
            int tmp = 0;
            string strTmp = "";
            int j = 0;
            for (int i = 0; i < Datas.Length; i++)
            {
                for (j = i; j < Datas.Length; j++)
                {
                    if (Datas[i] > Datas[j])
                    {
                        tmp = Datas[i];
                        Datas[i] = Datas[j];
                        Datas[j] = tmp;
                    }
                }
            }
            foreach (int i in Datas)
            {
                Console.WriteLine(i);
            }

            Console.Read();



        }
    }
}
原文地址:https://www.cnblogs.com/YuanDong1314/p/8967972.html