public int GetCount(int[] items) {
    return items.Length;
}const items = {
  foo: 1,
  bar: 2,
}
function getValueByKey(key) {
  return items[key];
}const items = [
  { key: 'foo', value: 1 },
  { key: 'bar', value: 2 },
]
function getValueByKey(key) {
  for (let i = 0; i < items.length; i++) {
    const item = items[i];
    if (item.key === key) {
      return item.value;
    }
  }
}скорость работы в данном случае зависит напрямую от количества элементов в массиве items,