I want to initialize a string,datetime
dictionary, I want a \"real\" time value for each string. Later I want to insert the strings into drop down list as keys and
Try this:
Dictionary testDictionary = new Dictionary()
{
{"1 hour", TimeSpan.FromHours(1) },
{"2 hour", TimeSpan.FromHours(2) },
{"3 hour", TimeSpan.FromHours(3) }
};
or use Add method of Dictionary as below:
Dictionary testDictionary = new Dictionary();
testDictionary.Add("1 Hour", TimeSpan.FromHours(1));