첨부 실행 코드는 나눔고딕코딩 폰트를 사용합니다.
------------------------------------------------------------------------------------------------------------------------------------------------------
728x90
728x170

■ Enumerable 클래스의 ElementAtOrDefault<T> 확장 메소드를 사용하는 방법을 보여준다.

 

▶ Program.cs

using System;
using System.Linq;

namespace TestProject
{
    /// <summary>
    /// 프로그램
    /// </summary>
    class Program
    {
        //////////////////////////////////////////////////////////////////////////////////////////////////// Method
        ////////////////////////////////////////////////////////////////////////////////////////// Static
        //////////////////////////////////////////////////////////////////////////////// Private

        #region 프로그램 시작하기 - Main()

        /// <summary>
        /// 프로그램 시작하기
        /// </summary>
        private static void Main()
        {
            int[] integerArray = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };

            // 에러가 발생한다.
            //Console.WriteLine("11번째 항목 : {0}", integerArray.ElementAt(10));

            Console.WriteLine("11번째 항목 : {0}", integerArray.ElementAtOrDefault(10));
        }

        #endregion
    }
}
728x90
그리드형(광고전용)
Posted by icodebroker
,