`

C#代码片段

    博客分类:
  • C#
 
阅读更多
private static List<MyPerson> dic2List(Dictionary<string, MyPerson> dic)
        {
            List<MyPerson> result = new List<MyPerson>();
            foreach (KeyValuePair<string, MyPerson> key in dic)
            {
                result.Add(key.Value);
            }
            return result;
        }

 

public class MyPerson : Person
    {
        private string name;
        private bool isFirstInDB;

        // 好的解决方法是:可以根据Name找到Person,不必使用Dictionary,而使用List
        public string Name
        {
            get { return name != null ? name : "NA"; }
            set { name = value; }
        }

        public bool IsFirstInDB
        {
            get { return isFirstInDB != null ? isFirstInDB : true; }
            set { isFirstInDB = value; }
        }
    }
 
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics