Tag: 索引器

C#索引器的真实世界用例?

我已经看到了很多c#索引器的例子,但在现实生活中它将以什么方式帮助我。 我知道C#大师不会添加这个,如果它不是一个严重的function,但我不能想到一个真实世界的情况下(而不是foo酒吧的东西)使用索引。 注意:我意识到存在一个相关的问题 ,但是对我没有多大帮助。

“奇怪的”C#属性语法

我刚刚在ac#项目中看到了这个: public char this[int index] 我认为自己是C#的新手; 任何人都可以帮助它是什么意思?

静态索引器?

为什么在C#中不允许使用静态索引器? 我看不出为什么他们不应该被允许,而且他们可能是非常有用的。 例如: static class ConfigurationManager { public object this[string name]{ get{ return 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 […]

Eclipse CDT索引器不知道C ++ 11容器

我在Eclipse CDT中configuration了一个C ++ 11项目来使用gcc-4.7。 这不是我的系统上的默认编译器,它不支持C ++ 11。 为了编译工作,我需要传递flag -std=c++11并且还包含以下头文件path: /usr/local/Cellar/gcc/4.7.2/gcc/include/c++/4.7.2 -std=c++11 /usr/local/Cellar/gcc/4.7.2/gcc/include/c++/4.7.2 每当我使用像std::unordered_set或std::unordered_map这样的C ++ 11容器types,CDT索引器就会抱怨: Symbol unordered_set could not be resolved 。 如何告诉索引器正确parsing这些符号? 这是我如何configuration我的索引器: 就我所了解的设置而言,索引器应该使用当前活动构buildconfiguration中的编译器设置。 编译工作正常,所以为什么不索引?