Profile Picture

Not a variable

Posted By phg 3 Years Ago
Message
phg
Supreme Being (46,887 reputation)Supreme Being (46,887 reputation)Supreme Being (46,887 reputation)Supreme Being (46,887 reputation)Supreme Being (46,887 reputation)Supreme Being (46,887 reputation)Supreme Being (46,887 reputation)Supreme Being (46,887 reputation)Supreme Being (46,887 reputation)
Posted Friday March 07 2014
I do not understand why this will not compile:
public class MySystem : MySystemBase
   public struct finalData {public string action; public double fast; public double slow; }
   public Dictionary passDict = new Dictionary(); // Final-bar trades?
.....
public class MySymbolScript : MySymbolScriptBase
   public override void Startup() {         // Set inputs.
      TradingSystem.passDict[Symbol.Name] = new MySystem.finalData();
.....
   public override void NewBar()
TradingSystem.passDict[baseSymbol].action="base";
      
The last line generates this error message:
"Error   Cannot modify the return value of 'System.Collections.Generic.Dictionary.this[string]' because it is not a variable"

-Pete

See also Yahoo group about applying RE.

phg
Supreme Being (46,887 reputation)Supreme Being (46,887 reputation)Supreme Being (46,887 reputation)Supreme Being (46,887 reputation)Supreme Being (46,887 reputation)Supreme Being (46,887 reputation)Supreme Being (46,887 reputation)Supreme Being (46,887 reputation)Supreme Being (46,887 reputation)
Posted Friday March 07 2014
I figured it out. I used a struct, which is a value type. So my offending line of code was trying to change the version on the stack (a copy), not the original version. The compiler detects that this would have been useless. How arcane is that!

The solution is to change the struct to a class, which is a reference type. Good to go.

-Pete

See also Yahoo group about applying RE.


Edited: Friday March 07 2014 by phg


Similar Topics


Reading This Topic


2005-2017 © RightEdge Systems