Questions tagged [indexer]

367 questions
3
votes
3 answers

ElementAt(index) on ICollection

As a heads up, I'm learning C# at the moment and going through a textbook when I ran into this obstacle. How do you call ElementAt from an IEnumerable? The second comment in this SO question mentions it, but I just get an error. Here they…
qdev76
  • 149
  • 1
  • 9
3
votes
2 answers

Indexer with default parameters

I know this is not a real world issue, but I wonder: can you access an indexer with all default parameters without reflection/tricks? For example how to call: public int this[string val="", int sth=5] { get { return 0; } …
Piotr Zierhoffer
  • 5,005
  • 1
  • 38
  • 59
3
votes
1 answer

"Item" property along with indexer

I've read the answers for Class with indexer and property named "Item", but they do not explain why can I have a class with multiple indexers, all of them creating Item property and get_Item/set_Item methods (of course working well, as they are…
Piotr Zierhoffer
  • 5,005
  • 1
  • 38
  • 59
3
votes
1 answer

How do I implement a sectioned list in Android?

I have a search feature which displays results in a ListView. I'm finding it difficult to implement an alphabetical sectioned list. Please give me idea of how to do it.
RajeshVijayakumar
  • 10,281
  • 11
  • 57
  • 84
3
votes
2 answers

Indexing collection properties with enums in XAML

While {Binding Path=CollectionProperty[2]} works fine, I can't get it working with an enum, i.e. {Binding Path=CollectionProperty[SomeEnum.Value2]}. What would be a proper syntax for that, if possible at all? Thanks.
Yegor
  • 2,514
  • 2
  • 19
  • 27
2
votes
1 answer

how to add separators in a listview at specific positions?

I have a ListView with custom Adapter . I have to add at position 2,6,9 separators. How to do that? Here is my code class MyIndexerAdapter extends ArrayAdapter implements SectionIndexer { ArrayList myElements; …
user1222905
  • 533
  • 2
  • 17
  • 36
2
votes
0 answers

Android AlphabetIndexer English and Hebrew(Unicode) togather

Following is my listview adapter classes using AlphabetIndexer. It does not work when I add unicode chars (for hebrew) togather with the english. I get exception in: getSectionForPosition. getting to index -1.... Tries it with 2 entries in the DB -…
user1136875
  • 613
  • 1
  • 9
  • 22
2
votes
0 answers

Indexer does not find printf/exit/fprintf (Eclipse + Qt + MinGW integration regarding stuff in stdio.h / stdlib.h / etc.)

I have a Qt Project and Eclipse started with the Qt Eclipse integration program. I am using the newest version of Qt (4.3.4), Eclipse and MinGW. My problem is, that the Eclipse Indexer does not find stuff like printf()/fprintf()/exit()! The code…
2
votes
4 answers

Item and this[] - Member with the same name is already declared

Possible Duplicate: Class with indexer and property named “Item” Just came across something I've not seen before and was wondering why this might be happening? With the following class, I get the compiler error "Member with the same name is…
Mike Rowley
  • 908
  • 9
  • 20
2
votes
4 answers

C# Indexer memory question

I have the following code inside main method: List rects = new List(); for (int i = 0; i < 5; i++) { rects.Add(new Rectangle(1, 1, 1, 1)); } foreach (Rectangle item in rects) { …
pkolodziej
  • 1,347
  • 3
  • 17
  • 24
2
votes
1 answer

"IndexError: .iloc requires numeric indexers, got [array([False, False, False, ..." in python. Why is it failing?

I am working with the implementation of Advances in Financial Machine Learning in order to get the scores of a cross validation in Python. The code I have is the next one: cv = PurgedKFold(n_splits = 10, samples_info_sets =…
jartymcfly
  • 1,945
  • 9
  • 30
  • 51
2
votes
2 answers

Why does generic list indexer show two behaviors

static void Main(string[] args) { var vs = new List { new Person(1) }; vs[0].IncrementAge(); Console.WriteLine(vs[0].Age); // output: 1 } struct Person { public int Age { get; set; } public Person(int age) : this() { …
2
votes
2 answers

C# Type as object with indexer

Consider a situation: I have a method which use DataRow: public void MyMethod (DataRow input) { DoSomething(input["Name1"]); } But now I have some another input types with indexer which I want to pass to this method. St like: public void…
xMichal
  • 624
  • 2
  • 7
  • 19
2
votes
2 answers

How to tweak Eclipse's C++ Indexer?

I'm using Eclipse as my IDE for a C++ project, and I would love for it to tell me where a given symbol is defined and what the parameters are for a function. However, there's a catch: I also use Lazy C++, a tool that takes a single source file and…
Carl Seleborg
  • 13,125
  • 11
  • 58
  • 70
2
votes
2 answers

How to fix Console Writing the name of the Class?

I am new to C# and I am struggling with this since hours and would appreciate your help. I want to create a Polygon and Write down each position of the points. Currently I have this: -Class Point class Point { private int x; private int…
carnito
  • 23
  • 3