This[r, c] saw this in some C# code, how is it possible?

  • Context: C# 
  • Thread starter Thread starter NotASmurf
  • Start date Start date
  • Tags Tags
    Code
Join the discussion
Registration is free. Ask a follow-up in this thread, or start your own.
1 reply · 1K views
NotASmurf
Messages
150
Reaction score
2
Hey all, I was looking at some example code where they said "this[r, c] = sourceMatrix[r, c];"
where sourcematrix is double[][] but its in a custom local class, the code runs and works. but I am confused as to what "this[r, c]" does, how can a custom class be an array of doubles at the same time?? Any help appreciated.
 
Physics news on Phys.org
Sorry nevermind, seems you can overload c# keywords now.
Code:
 public double this[int row, int col]
        {
            get
            {
                return this.matrix[row, col];
            }
            set
            {
                this.matrix[row, col] = value;
            }
        }
 
  • Like
Likes   Reactions: harborsparrow and WhatHitMe