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 egordleo, Today, 05:50 AM
          0 responses
          4 views
          0 likes
          Last Post egordleo  
          Started by kevinenergy, 02-17-2023, 12:42 PM
          118 responses
          2,778 views
          1 like
          Last Post kevinenergy  
          Started by briansaul, Today, 05:31 AM
          0 responses
          9 views
          0 likes
          Last Post briansaul  
          Started by fwendolynlpxz, Today, 05:19 AM
          0 responses
          4 views
          0 likes
          Last Post fwendolynlpxz  
          Started by traderqz, Yesterday, 12:06 AM
          11 responses
          28 views
          0 likes
          Last Post NinjaTrader_Gaby  
          Working...
          X