Almost to the right is K capital for Key , not lower case. C # is case sensitive.
In addition, object does not have a Key member. In C #, you can use implicit type inference with the var keyword. This will work if the underlying candidate type has a Key member:
HttpContext oc = HttpContext.Current; foreach (var c in oc.Cache) { oc.Response.Write(c.Key.ToString()); }
In this case, Cache does not have a Key member, so you need to dig deeper using the IDictionaryEnumerator returned by the GetEnumerator Cache method:
HttpContext oc = HttpContext.Current; IDictionaryEnumerator en = oc.Cache.GetEnumerator(); while(en.MoveNext()) { oc.Response.Write(en.Key.ToString()); }
Odded source share