static-indexers

Static Indexers?

僤鯓⒐⒋嵵緔 提交于 2019-11-26 17:33:29
Why are static indexers disallowed in C#? I see no reason why they should not be allowed and furthermore they could be very useful. For example: public static class ConfigurationManager { public object this[string name] { get => ConfigurationManager.getProperty(name); set => ConfigurationManager.editProperty(name, value); } /// <summary> /// This will write the value to the property. Will overwrite if the property is already there /// </summary> /// <param name="name">Name of the property</param> /// <param name="value">Value to be wrote (calls ToString)</param> public static void editProperty

Static Indexers?

流过昼夜 提交于 2019-11-26 04:46:00
问题 Why are static indexers disallowed in C#? I see no reason why they should not be allowed and furthermore they could be very useful. For example: public static class ConfigurationManager { public object this[string name] { get => ConfigurationManager.getProperty(name); set => ConfigurationManager.editProperty(name, value); } /// <summary> /// This will write the value to the property. Will overwrite if the property is already there /// </summary> /// <param name=\"name\">Name of the property<