奇怪的是,我有两个枚举集:
public enum ComponentActionTypes {
Add = 0,
Move = 1,
Delete = 2,
Edit = 3,
Enable = 4,
Disable = 5
}
public enum ComponentNames {
Component = 0,
Logo = 1,
Main_menu = 2,
Search_box = 3,
Highlighter = 4,
RSS = 5,
Twitter = 6,
YouTube = 7
}
当我尝试打印以下文本时,
ActionText =
string.Format("{0}ed a {1}", action.ComponentActionType, action.ComponentName);
将产生:
184ed a Logo
代替Added a Logo
action.ComponentActionType
被转换为数字(ToString
没有帮助),也是一个
奇怪184
的数字(比如,不是枚举数本身)
知道如何解决这个问题吗?
更新:
namespace BrandToolbar.Common.ActionLog.Model
{
public class ActionItem
{
public Guid UserId { get; set; }
public Int64 PublicId { get; set; }
public ComponentActionTypes ComponentActionType { get; set; }
public DateTime Date { get; set; }
public ComponentNames ComponentName { get; set; }
public string UiJsonPreview { get; set; }
}
}
public static ActionItemUI ConvertModelToUiObj(ActionItem action)
{
return new ActionItemUI()
{
ActionText = string.Format(
"{0}ed a {1}",
action.ComponentActionType,
action.ComponentName
).Replace("_", " "),
TooltipText = string.Format(
"{0}ed on {1}",
action.ComponentActionType,
action.Date.ToString(StringFormatter.DateFormat)
),
ImageUrl = string.Empty,
ConponentText = string.Empty
};
}