반응형

using System;

using System.Collections.Generic;

using System.Linq;

using System.Text;

using System.Threading.Tasks;


namespace Dev_Console

{

    class Program

    {


        private static bool CheckPassed(int score)

        {

            if (score >= 60)

                return true;

            else

                return false;

        }


        private static void Print(int value)

        {

            Console.Write("{0} ", value);

        }


        public static void Main(string[] args)

        {

            int[] scores = new int[] { 80, 74, 81, 90, 34 };


            foreach (int score in scores)

            {

                Console.Write("{0} ", score);

            }

            Console.WriteLine();


            Array.Sort(scores);

            Array.ForEach<int>(scores, new Action<int>(Print));

            Console.WriteLine();


            Console.WriteLine("Number of dimensions : {0}", scores.Rank);


            Console.WriteLine("Binary Search : 81 is at {0}", Array.BinarySearch<int>(scores, 81));

            Console.WriteLine("Linear Search : 90 is at {0}", Array.IndexOf(scores, 90));


            Console.WriteLine("Everyone passed ? : {0}", Array.TrueForAll<int>(scores, CheckPassed));


            int index = Array.FindIndex<int>(scores, delegate(int score)

            {

                if (score < 60)

                    return true;

                else

                    return false;

            });


            scores[index] = 61;

            Console.WriteLine("Everyone passed ? : {0}", Array.TrueForAll<int>(scores, CheckPassed));


            Console.WriteLine("Old length of scores : {0}", scores.GetLength(0));


            Array.Resize<int>(ref scores, 10);

            Console.WriteLine("New length of scores : {0}", scores.Length);


            Array.ForEach<int>(scores, new Action<int>(Print));

            Console.WriteLine();


            Array.Clear(scores, 3, 7);


            Array.ForEach<int>(scores, new Action<int>(Print));

            Console.WriteLine();

        }


    }






}

반응형

'Program > C#' 카테고리의 다른 글

c# vb 변환  (0) 2011.10.26
닷넷!! All-In-One Code Framework!!  (0) 2011.03.24
.NET 개발자를 위한 무료 소프트웨어  (0) 2011.03.24
디렉토리 안에 폴더 삭제 하기  (0) 2011.03.24
다중서버관리  (0) 2011.03.24

+ Recent posts