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.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.

{(int)cust.OneTime, "some string values"}
}
Rajanikant HawaldarPosted Jul 22, 2021, 5:54 AM
AndyPosted Jul 22, 2021, 6:51 AM
Nirmal DayalPosted Jul 22, 2021, 6:39 AM
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" }
};
Sachin SinghPosted Jul 22, 2021, 6:28 AM