79358286

Date: 2025-01-15 12:57:15
Score: 1
Natty:
Report link

I'm sure that you have moved on by now (15 years later), but for future references, today it can be done like this:

// Not using TryGetValue
var theString = dict[key] as string;
    
// Using trygetValue
if(dict.TryGetValue(key, out obj) && obj is string theString) 
{
}
Reasons:
  • Low length (0.5):
  • Has code block (-0.5):
  • Low reputation (1):
Posted by: DanielMuhlig