2

Not sure how to meet the demands of stackoverflow on this one...

I'd like to modify the MathNET Numerics package so that I can use the indexer to access or assign to a sub-matrix as follows:

A[rows, cols] 

where rows and cols are int[]

I've written an extension method Sub(int[] rows, int[] cols) which achieves the same but it would be smarter to have the indexing manner.

IS it possible to add an extension of the indexer without rebuilding the whole package? If so how?

gwizardry
  • 501
  • 1
  • 6
  • 19

1 Answers1

5

No, there's no such thing as an "extension indexer" right now. Extension methods are as close as you can get. However, it's entirely possible (but not guaranteed) that they'll come in C# 8. So your options are:

  • Wait for C# 8
  • Use your own private fork of the library
  • Try to get your changes accepted into the library
  • Stick to extension methods
Jon Skeet
  • 1,421,763
  • 867
  • 9,128
  • 9,194
  • 1
    Taken a while but managed to create my own version of the library in the end (and suggested they add it to the next release...dont see any obvious downsides). Thanks – gwizardry Jul 20 '17 at 22:50