I have the following enum
:
public enum Event0Instance
{
ClaimSent,
RequestSent,
ClaimResponseAqcuired,
RequestResponseAqcuired,
RequestRefusalAcquired,
}
With this enum
I've made dictionary Dictionary<Event0Instance, string>
where string
value is the text description of each enum value:
public static Dictionary<Event0Instance, string> Event0Descriptions =
new Dictionary<Event0Instance, string>()
{
{Event0Instance.ClaimSent, "Подана претензия" },
{Event0Instance.RequestSent, "Подан запрос"},
{Event0Instance.ClaimResponseAqcuired, "Получен ответ на претензию"},
{Event0Instance.RequestResponseAqcuired, "Получен ответ на запрос"},
{Event0Instance.RequestRefusalAcquired, "Получен отказ на запрос"}
};
The obvious problem here is the need to repeat Event0Instance. with each entry. There are more enum
s, each bigger than the one in the example, if I want to make a Dictionary
for each of them it's a huge code repetition.
In VBA language there is a With
/ End With
construct which you could use like this:
With Person
.FirstName = "John"
.LastName = "Smith"
.Age = 23
End With
Is there somethings similar in C#?