表示提要中摘要信息的RssEntry类

RssEntry类用来表示RSS阅读器左边导航栏中的提要列表中的条目,该类摘要性地保存了提要的标题(Title属性)、提要的URL(Url属性)以及该提要的ID(Id属性)。RssEntry类的类图如图11-6所示。

  RssEntry类的完整声明如下。注意其中的静态方法CreateNew(),用来根据提要的标题和URL创建一个新的RssEntry对象,该对象的Id属性由CreateNew()方法负责维护,以便保证唯一性:

  表示提要中摘要信息的RssEntry类

  图11-6 RssEntry类的类图

 public class RssEntry
  {
    private static int nextId = 0;
    /// <summary>
    /// 根据标题和URL创建新的RssEntry对象。
    /// </summary>
    /// <param name="title">标题</param>
    /// <param name="url">URL</param>
    /// <returns>新的RssEntry对象</returns>
    public static RssEntry CreateNew(string title, string url)
    {
      RssEntry newEntry = new RssEntry();
      newEntry.Id = nextId++;
      newEntry.Title = title;
      newEntry.Url = url;
      return newEntry;
    }
    private int m_id;
    public int Id
    {
      get { return m_id; }
      set { m_id = value; }
    }
    private string m_title;
    public string Title
    {
      get { return m_title; }
      set { m_title = value; }
    }
    private string m_url;
    public string Url
    {
      get { return m_url; }
      set { m_url = value; }
    }
    public RssEntry()
    {
    }
  }

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值