using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace YLErp.Enums { [Flags] public enum BuySellEnum { None = 0, /// /// 买入 /// Buy = 1 << 0, /// /// 卖出 /// Sell = 1 << 1, /// /// 全部 /// All = Buy | Sell } public static class BuySellUtil { /// /// 获取枚举描述 /// public static string GetDesc(BuySellEnum type) { return InnerGetDesc(type); } private static string InnerGetDesc(BuySellEnum type) { switch (type) { case BuySellEnum.Buy: return "买入"; case BuySellEnum.Sell: return "卖出"; default: break; } var nt = (int)type; var list = new List(2); for (var i = 0; i <= 1; i++) { if ((nt & (1 << i)) > 0) { type = (BuySellEnum)(1 << i); list.Add(InnerGetDesc(type)); } } return string.Join(",", list); } } }