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

TestProject.zip
다운로드

▶ School.cs

namespace TestProject
{
    /// <summary>
    /// 학교
    /// </summary>
    public class School
    {
        //////////////////////////////////////////////////////////////////////////////////////////////////// Property
        ////////////////////////////////////////////////////////////////////////////////////////// Public

        #region ID - ID

        /// <summary>
        /// ID
        /// </summary>
        public int ID { get; set; }

        #endregion
        #region 명칭 - Name

        /// <summary>
        /// 명칭
        /// </summary>
        public string Name { get; set; }

        #endregion
    }
}

 

728x90

 

▶ Program.cs

using System;

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

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

        /// <summary>
        /// 프로그램 시작하기
        /// </summary>
        private static void Main()
        {
            string description = GetDescription(new School { ID = 3, Name = "보성고" });

            Console.WriteLine(description);
        }

        #endregion

        #region 설명 구하기 - GetDescription(school)

        /// <summary>
        /// 설명 구하기
        /// </summary>
        /// <param name="school">학교</param>
        /// <returns>설명</returns>
        private static string GetDescription(School school) => (school.ID, school.Name) switch
        {
            (1, "동북고") => "남자 학교",
            (2, "영파고") => "여자 학교",
            (3, "보성고") => "남자 학교",
            (_, _       ) => "해당 무"
        };

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

댓글을 달아 주세요