| Author: vipul 08 Jul 2008 | Member Level: Diamond | Rating: Points: 6 |
hi, sorry it is my mistake you don't use direct string into enum for that you used this way using System.ComponentModel; public partial class zzTest : System.Web.UI.Page { public enum Foobar { [Description("captain")] C = 1, [Description("fe")] E = 3, }
protected void Page_Load(object sender, EventArgs e) { Response.Write(GetDescription(Foobar.C)); } public string GetDescription(Enum value) { System.Reflection.FieldInfo fi = value.GetType().GetField(value.ToString()); System.ComponentModel.DescriptionAttribute[] attributes = (System.ComponentModel.DescriptionAttribute[])fi.GetCustomAttributes( typeof(System.ComponentModel.DescriptionAttribute), false); return (attributes.Length > 0) ? attributes[0].Description : value.ToString(); }
}
Patel Vipul Web Developer Ahmedabad ( Gujarat )
|
| Author: tejaswini 08 Jul 2008 | Member Level: Bronze | Rating: Points: 3 |
hi... still i'm getting the same error
Error 1 The type or namespace name 'UI' does not exist in the namespace 'System.Web' (are you missing an assembly reference?)
|