First of all, I'm NOT really familiar with C#, but I am with C++. I didn't find any info about this. Through what mechanism is a C# property is being set when it only have a get implemented and the set is hidden. It's a read-only property that is being set continuously, inside a loop.
My hunch is that the get returns a reference which C# uses to set the value in this case. Is that correct?
(I've come across a code which I'm trying to understand)
For example:
public Series<double> Avg
{
get { return Values[1]; }
}
public Series<double> Default
{
get { return Values[0]; }
}
(Series is just an array of doubles, but accessing them from the end of the array, by index)
The code in RSI does write the items of the array:
Default[0] = value0;
Avg[0] = constant1 * value0 + constant2 * Avg[1];
So what is happening up there? Just to understand, it is something like the below C++ code?
double& Avg(int index)
{
return Values[index+1];
}
Certainly, in C++ you would use Avg(1)
instead of Avg[1]
since it is a function, I'm just curious what the logic actually does in @RSI.cs. Is the get in this case is like a reference so it can also write values via the get or is the set is auto-implemented so writing and reading the above properties is accessing a completely different index or even variable?
Are the above C# samples even a valid C# code?