indexed-properties

Why C# doesn't implement indexed properties ?

I know, I know... Eric Lippert's answer to this kind of question is usually something like "because it wasn't worth the cost of designing, implementing, testing and documenting it". But still, I'd like a better explanation... I was reading this blog post about new C# 4 features, and in the section about COM Interop, the following part c...

Is following Indexer property possible?

Suppose I have an array or any other collection for that matter in class and a property which returns it like following: public class Foo { public IList<Bar> Bars{get;set;} } Now, may I write anything like this: public Bar Bar[int index] { get { //usual null and length check on Bars omitted for calarity re...

Easy creation of properties that support indexing in C#

In C# I find indexed properties extremely useful. For example: var myObj = new MyClass(); myObj[42] = "hello"; Console.WriteLine(myObj[42]); However as far as I know there is no syntactic sugar to support fields that themselves support indexing (please correct me if I am wrong). For example: var myObj = new MyClass(); myObj.field...

Deleting an item from an indexed property - JavaBeans question

I'm working with indexed properties (using struts and java/jsp). We have a dynamic table that can add/delete rows/items in the table. The adding of rows works as intended - I see the new rows in the form in the action class. The deleted rows do not get set (obviously), but they are also not removed from the list. I have implemented a voi...