public static string TheColor(string color,string enumName)
{
return string.Format("<span style=/"color={0}/">{1}</span>",color,enumName);
}
public enum YesOrNo
{
NO=0,
Yes=1
}
/// <summary>
/// 将“‘是、否’枚举”转化为文本(中文)
/// </summary>
/// <param name="yn">“是、否”枚举</param>
/// <param name="withColor">是否着色</param>
/// <returns></returns>
public static string YesOrNos(YesOrNo yn, bool withColor)
{
string result = string.Empty;
if (withColor)
{
switch (yn)
{
case YesOrNo.NO: result = TheColor("Red", "是"); break;
case YesOrNo.Yes: result = TheColor("Green", "否"); break;
default: break;
}
}
else
{
switch(yn)
{
case YesOrNo.NO:result=" 否";break;
case YesOrNo.Yes:result="是";break;
default:break;
}
}
return result;
}