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 charlesugo_1, 05-26-2026, 05:03 PM
          0 responses
          66 views
          0 likes
          Last Post charlesugo_1  
          Started by DannyP96, 05-18-2026, 02:38 PM
          1 response
          149 views
          0 likes
          Last Post NinjaTrader_ChelseaB  
          Started by CarlTrading, 05-11-2026, 05:56 AM
          0 responses
          162 views
          0 likes
          Last Post CarlTrading  
          Started by CarlTrading, 05-10-2026, 08:12 PM
          0 responses
          99 views
          0 likes
          Last Post CarlTrading  
          Started by Hwop38, 05-04-2026, 07:02 PM
          0 responses
          286 views
          0 likes
          Last Post Hwop38
          by Hwop38
           
          Working...
          X