【愚公系列】2021年11月 C#版 数据结构与算法解析(映射)

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Badao.Entity.Helper
{
    public class StepStateHelper
    {
        #region 单例实现
        private static string _lockFlag = "StepStateHelperLock";
        private static StepStateHelper _instance;
        private StepStateHelper()
        {

        }
        public static StepStateHelper Instance
        {
            get
            {
                lock(_lockFlag)
                {
                    if (_instance == null)
                    {
                        _instance = new StepStateHelper();
                    }
                    return _instance;
                }
            }
        }
        #endregion
        #region 字段定义
        private Dictionary<short, string> _dicStepStates = new Dictionary<short, string>() 
        { 
            { 0x04, "霸道" },
            { 0x05, "流氓" },
            { 0x06, "气质" },
        };
        #endregion
        #region 属性定义
        public Dictionary<short, string> DicStepStates
        {
            get
            {
                return _dicStepStates;
            }
        }
        #endregion
    }
}
string StepState = "";
StepStateHelper.Instance.DicStepStates.TryGetValue((short)obj, out StepState);

以上就是基本类映射的实现

上一篇:Illustrator(AI)设计打造三只颜色的可爱的卡通小鸟实例教程


下一篇:PhotoShop(PS)设计一幅具有超现实感的石屋风景照片实例教程