var resultWeekday = ToEnum("St");
var resultShort = ToShort(Weekday.Friday);
Console.WriteLine(resultWeekday);
Console.WriteLine(resultShort);
public string ToShort(Weekday enumValue)
var type = enumValue.GetType();
var fieldInfo = type.GetField(enumValue.ToString());
var attr = fieldInfo.GetCustomAttributes(typeof(ShortName), false) as ShortName[];
public Weekday ToEnum(string shortString)
var type = typeof(Weekday);
foreach(var field in type.GetFields())
var attribute = Attribute.GetCustomAttribute(field, typeof(ShortName)) as ShortName;
if(attribute.Name == shortString)
return (Weekday)field.GetValue(null);
throw new ArgumentException("Not found", shortString);
public class ShortName : Attribute
public ShortName(string name)