私は次の列挙型を持っています:
public enum QuestionType {
Check = 1,
CheckAndCode = 2,
na = 99
};
public static class QuestionTypeExtension
{
public static string D2(this QuestionType key)
{
return ((int) key).ToString("D2");
}
}
出力をフォーマットする拡張メソッドを既に作成しましたが、別の要件があります。私がする必要があるのは、列挙型の内容を次のクラスのリストに返す拡張メソッドを作成することです。
public class Reference {
public string PartitionKey { get; set; } // set to "00"
public int RowKey { get; set; } // set to the integer value
public string Value { get; set; } // set to the text of the Enum
}
拡張メソッドでこれを行うことは可能ですか?