Announcement

Collapse
No announcement yet.

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?


    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 CarlTrading, 03-31-2026, 09:41 PM
          1 response
          133 views
          1 like
          Last Post NinjaTrader_ChelseaB  
          Started by CarlTrading, 04-01-2026, 02:41 AM
          0 responses
          75 views
          1 like
          Last Post CarlTrading  
          Started by CaptainJack, 03-31-2026, 11:44 PM
          0 responses
          117 views
          2 likes
          Last Post CaptainJack  
          Started by CarlTrading, 03-30-2026, 11:51 AM
          0 responses
          113 views
          1 like
          Last Post CarlTrading  
          Started by CarlTrading, 03-30-2026, 11:48 AM
          0 responses
          90 views
          0 likes
          Last Post CarlTrading  
          Working...
          X