Comment the interface, implementation or both?

后端 未结 9 1270
萌比男神i
萌比男神i 2020-12-13 03:08

I imagine that we all (when we can be bothered!) comment our interfaces. e.g.

/// 
/// Foo Interface
/// 
public interface Fo         


        
9条回答
  •  野趣味
    野趣味 (楼主)
    2020-12-13 03:58

    C# usage:

    Interface can look like this:

        /// 
        /// Helper class to access various properties for the current site.
        /// 
        public interface ISiteHelper
        {
            /// 
            /// Gets the site id of the current site
            /// 
            /// The site id.
            int GetSiteID();
        }
    }
    

    Implementation can look like this:

    /// 
    public class SiteHelper: ISiteHelper
    {
        /// 
        public int GetSiteID()
        {
            return CommonRepository.GetSiteID();
        }
    }
    

提交回复
热议问题