0
<%
foreach (System.Collections.DictionaryEntry entry in HttpContext.Current.Cache){
HttpContext.Current.Cache.Remove((string)entry.Key);
}
foreach (int key in diamondMethodList)
{
Response.Write(string.Format("<option value=\"{0}\">{1}</option>", key, diamondMethodList[key]));
}
%>
Hello I’m having a small error in foreach, how do I convert? if I change the key int to key string from the following error in diamondMethodList[key]: it is not possible to implicitly convert type "string" to "int"
What is
diamondMethodList
? You are playing a string list in an integer.– Marconi
you can’t know without knowing the diamondMethodList statement, but assuming it’s a string list do the conversion inside the loop with
Int32.TryParse()
or if you are sure that the list only contains numbers you can useConvert.ToInt32()
as answered below– JMSlasher