Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Class member declaration expected

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Class member declaration expected

    I'm getting this error for this line, but it doesn't prevent compile, it just shows as an error until I compile - and it works. What's it complaining about?

    private Dictionary<(marketConditionName, double), marketConditionPerformanceTracker> marketConditionScoring = new Dictionary<(marketConditionName, double), marketConditionPerformanceTracker>();

    #2
    Hello Skifree,

    That is due to the dictionary parameters. While that is valid in C# the NinjaScript editor sees that as invalid due to the parenthesis in the dictionary type. ere you trying to use a tuple as the key? If so that needs to be defined like the following to avoid that error:

    Code:
    private Dictionary<Tuple<marketConditionName, double>, marketConditionPerformanceTracker> marketConditionScoring = new Dictionary<Tuple<marketConditionName, double>, marketConditionPerformanceTracker>();

    Comment


      #3
      Correct the tuple is a key, effectively a third column in the dictionary

      Comment


        #4
        Hello Skifree,

        Thanks for confirming. You should be able to use the code I provided in my last reply for that use case. You just need to use the format Tuple<T,T> instead.

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by CarlTrading, 05-11-2026, 05:56 AM
        0 responses
        23 views
        0 likes
        Last Post CarlTrading  
        Started by CarlTrading, 05-10-2026, 08:12 PM
        0 responses
        17 views
        0 likes
        Last Post CarlTrading  
        Started by Hwop38, 05-04-2026, 07:02 PM
        0 responses
        182 views
        0 likes
        Last Post Hwop38
        by Hwop38
         
        Started by CaptainJack, 04-24-2026, 11:07 PM
        0 responses
        335 views
        0 likes
        Last Post CaptainJack  
        Started by Mindset, 04-21-2026, 06:46 AM
        0 responses
        259 views
        0 likes
        Last Post Mindset
        by Mindset
         
        Working...
        X