Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

Partner 728x90

Collapse

How to create List, string

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

    How to create List, string

    Hi Support, I am trying to create a List string similar to this:
    Code:
    var dogs = new List<string>(); // Create new list of strings
    	dogs.Add("Aigi"); // Add string 1
    	dogs.Add("Spitz"); // 2
    	dogs.Add("Mastiff"); // 3
    	dogs.Add("Finnish Spitz"); // 4
    	dogs.Add("Briard"); // 5
    
    	string dogCsv = string.Join(",", dogs.ToArray());
    but I'm unable to compile in NT, I get an error message saying the namespace name List could not be found, see attached pic. Any idea how I can get this to work?
    Attached Files

    #2
    Originally posted by yades View Post
    Hi Support, I am trying to create a List string similar to this:
    Code:
    var dogs = new List<string>(); // Create new list of strings
    	dogs.Add("Aigi"); // Add string 1
    	dogs.Add("Spitz"); // 2
    	dogs.Add("Mastiff"); // 3
    	dogs.Add("Finnish Spitz"); // 4
    	dogs.Add("Briard"); // 5
    
    	string dogCsv = string.Join(",", dogs.ToArray());
    but I'm unable to compile in NT, I get an error message saying the namespace name List could not be found, see attached pic. Any idea how I can get this to work?
    Create a new List, add elements to it, and loop over its elements with for and foreach.


    Try adding this at the top:

    using System.Collections.Generic;

    Comment


      #3
      Hello yades,

      Thanks sledge, yes you would have to add the "System.Collections.Generic" namespace. This is due to the fact that NinjaTrader does not support Lists but it still would be possible to use them as they are a native C# method.

      Here is a link that goes over the List Class and also shows the namespace and assembly file that are associated with it that you may view.
      Represents a strongly typed list of objects that can be accessed by index. Provides methods to search, sort, and manipulate lists.
      JCNinjaTrader Customer Service

      Comment


        #4
        try this one...C# list

        Comment


          #5
          walshmagger

          Very helpful site. Thx!

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by bortz, 11-06-2023, 08:04 AM
          47 responses
          1,603 views
          0 likes
          Last Post aligator  
          Started by jaybedreamin, Today, 05:56 PM
          0 responses
          8 views
          0 likes
          Last Post jaybedreamin  
          Started by DJ888, 04-16-2024, 06:09 PM
          6 responses
          18 views
          0 likes
          Last Post DJ888
          by DJ888
           
          Started by Jon17, Today, 04:33 PM
          0 responses
          4 views
          0 likes
          Last Post Jon17
          by Jon17
           
          Started by Javierw.ok, Today, 04:12 PM
          0 responses
          12 views
          0 likes
          Last Post Javierw.ok  
          Working...
          X