why cannot i initialise a dictionary with values from enum. for example
enum cust {
OneTime
}
dictionary
{cust.OneTime, "some string values"}
}
getting argument is not assignable to type int error
any thoughts?
why cannot i initialise a dictionary with values from enum. for example
enum cust {
OneTime
}
dictionary
{cust.OneTime, "some string values"}
}
getting argument is not assignable to type int error
any thoughts?
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Rajanikant HawaldarRank #110 · 20.2K reputationPosted Jul 22, 2021, 1:54 AM EDT
Anupam MaitiRank #295 · 8.5K reputationPosted Jul 22, 2021, 2:05 AM EDT
{(int)cust.OneTime, "some string values"}
}
Sachin SinghRank #66 · 26.2K reputationPosted Jul 22, 2021, 2:28 AM EDT
Nirmal DayalRank #1,711 · 886 reputationPosted Jul 22, 2021, 2:39 AM EDT
There are three ways to perform :
Dictionary keyValuePairs1 = new Dictionary
{
{ (int)Flat.O101, "O-105" }
};
Dictionary keyValuePairs2 = new Dictionary
{
{ Flat.O101, "O-105" }
};
Dictionary keyValuePairs3 = new Dictionary
{
{ Convert.ToInt32(Flat.O101), "O-105" }
};
Andy34 reputationPosted Jul 22, 2021, 2:51 AM EDT