CSharp · Console
using System;
using System.Collections.Generic;
public static class Program
{
public static void Main(string[] args)
{
var item = new ItemWithIndexer
{
["1"] = "value"
};
Console.WriteLine(item["1"]);
}
}
public class ItemWithIndexer
{
private readonly Dictionary<string, string> _dictionary = new Dictionary<string, string>();
public string this[string index]
{
get { return _dictionary[index]; }
set { _dictionary[index] = value; }
}
}