[파일명:  TestSortApp.cs]------------------------------------------------
using System;
using System.Collections;
using System.Collections.Generic;

namespace MyTestApplication1 {

    class TestSortApp {

        public static void Main(String[] args) {
            String[] arr = new String[args.Length];
            for (int i = 0; i < args.Length; i++) {
                arr[i] = args[i];
            }
            Array.Sort(arr);
            PrintArray(arr);
        }

        public static void PrintArray(Object[] arr) {
            Console.Write("[");
            for (int i = 0; i < arr.Length - 1; i++) {
                Console.Write("{0}, ", arr[i]);
            }
            if (arr.Length > 0)
                Console.Write("{0}", arr[arr.Length - 1]);
            Console.WriteLine("]");
        }
    }
}
------------------------------------------------


컴파일> csc TestSortApp.cs

실행> TestSortApp one two three four five
[five, four, one, three, two]

실행> TestSortApp 하나 둘 셋 넷 다섯
[넷, 다섯, 둘, 셋, 하나]


 

크리에이티브 커먼즈 라이선스
Creative Commons License

 

Posted by Scripter
,