C# array of object indexing in matlab

5 次查看(过去 30 天)
In matlab, I have array of c# objects and I want to select the object on index position 1.
doc.Workbook.Worksheets
ans =
ExcelWorksheets with properties:
Count: 3
I tried to use small, curly and square brackets to access the object and I am getting following errors:
Array formation and indexing are not allowed on .NET objects.
doc.Workbook.Worksheets[1]
|
Error: Unbalanced or unexpected parenthesis or bracket.

采纳的回答

Guillaume
Guillaume 2014-8-26
编辑:Guillaume 2014-8-26
Use the Item method:
doc.Workbook.Worksheets.Item(1)
It's part of the IList interface which all arrays implement.
  1 个评论
Observer
Observer 2014-8-26
Your answer is partially correct. If I execute above statement without placing semicolon in end then I get error.

请先登录,再进行评论。

更多回答(1 个)

Image Analyst
Image Analyst 2014-8-26
Try parentheses instead of brackets: doc.Workbook.Worksheets(1)
  1 个评论
Observer
Observer 2014-8-26
I tried this approach and was getting following error: Array formation and indexing are not allowed on .NET objects.

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Matrix Indexing 的更多信息

标签

产品

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by