zl程序教程

您现在的位置是:首页 >  其他

当前栏目

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

2023-04-18 14:26:46 时间
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);

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