❔ Is this good practice with public accessors?

I come from C++ which used get/sets to access private members. In C#, there seems to be several ways of doing this. I learned the latest one. It seems like less time accessing these probbaly due to less function call overhead.

I'm creating a CustomDateTime class that's specific toward a game I'm working on. Is below good practice of using these public accessors? I assume the rule is if it fits in one line (member variable or expression), it's good practice?

        // Accessors 
        //
        // Hour
        public int Hour => (m_hour24 > 12) ? m_hour24 - 12 : m_hour24;
        public int Hour24 => m_hour24;
        public string AMPM => (m_hour24 >= 12) ? "PM" : "AM";
        // Minute
        public int Minute => m_minute;
        // Second
        public int Second => m_second;
        // Year
        public int Year => m_year;
        public string ShortYear => m_year.ToString().Substring(m_year.ToString().Length - 2, 2);
        // Month
        public int Month => m_month;
        public int MonthCount => m_monthNames.Count();
        public string MonthName => m_monthNames[m_month - 1];
        public string MonthNameAbbr => m_monthNamesAbbr[m_month - 1];
        // Day
        public int Day => m_dayOfMonth;
        public int DaysPerMonth => m_daysPerMonth;
        public int DayOfYear => ((m_month - 1) * m_daysPerMonth) + m_dayOfMonth; 
        public string WeekdayName => m_weekdayNames[(m_dayOfMonth - 1) % 7];
        // Format
        public string LetterDate => String.Format("{0} {1}, {2}",  m_weekdayNames[(m_dayOfMonth - 1) % 7], m_dayOfMonth, Year);
        public string ShortDate => String.Format("{0}/{1}/{2}", m_month, m_dayOfMonth, ShortYear);
        public string Time => String.Format("{0}:{1:00} {2}", Hour, m_minute, AMPM);
        public string Time24 => String.Format("{0}:{1:00}", m_hour24, m_minute); 
Was this page helpful?