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);
以上就是基本类映射的实现