IronShay

Ironing code, geek t-shirts and even presentations!

NAVIGATION - SEARCH

IronRuby Tip: Access .Net Indexers

The Problem

IronRuby Tip: Access .Net Indexers  Currently, if you have a .Net class you want to access via IronRuby, and you have an indexer there (like myObject[2]), you won't be able to use the indexer with brackets [] from IronRuby. You'll get an exception.

The Solution

Use get_Item(index) instead (pay attention to casing).

Example

my_dataset.Tables[0] # <-- This won't work
my_dataset.Tables.get_Item(0) # <-- This will work great!
All the best,
Shay.

Pingbacks and trackbacks (1)+

Add comment