3
$\begingroup$

I have a property in .NET Type, which is actually a generic list of objects. When I try access the property using numeric index e.g. 10, this works. However when I iterate through indices using indexer such as i, then I get error "NET::nofield: No public field or property named i exists for the .NET type ..."

How to resolve this?

$\endgroup$
1
  • 1
    $\begingroup$ Could you please share your Mathematica code that is causing the error? $\endgroup$
    – rhermans
    Apr 1, 2014 at 15:04

1 Answer 1

3
$\begingroup$

I figured it out, I need to use Item indexer, but item index starts from 0, not 1:

If you write a class in C# and give it an indexer, the compiler creates a public property named Item for you. This is a parameterized property, meaning that it takes an argument like a method call. The indexer syntax is just a shorthand for calling the Item property.

See

Calling .NET from the Wolfram Language: Indexers

$\endgroup$
2
  • 2
    $\begingroup$ It would be great if you could add some simple example code to this answer. It will make it more useful for anyone else facing the same problem who finds this Q&A. $\endgroup$ Apr 1, 2014 at 15:56
  • 1
    $\begingroup$ i added more details and direct link $\endgroup$
    – den.run.ai
    Apr 20, 2014 at 4:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.