private string RejectKeyIfNotString(object keyObj) { if (!(keyObj is string)) { throw new ArgumentException("Only keys of type string can be provided.", "key"); } return (string)keyObj; } }