• If this is your first visit, you will have to register before you can post. To view messages, please scroll below and select the forum that you would like to visits. Questions? Be sure to check out the Forum FAQ.

Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

How to: Mixed-type, multidimensional array?

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

    How to: Mixed-type, multidimensional array?

    Sorry to ask a basic programming question, but C# is not my native language.

    I want an array that looks like this:

    Array[1,534.2]="Some string value". So I have Array[number,number]=string.

    How do you do this in C#?

    I tried this:

    private double[,] = new Array[6,6];

    But it seems that the array cannot have a string as a value.
    Last edited by cassb; 11-03-2008, 08:00 AM.
    cassb
    NinjaTrader Ecosystem Vendor - Logical Forex

    #2
    Please try
    private string[,] myArray = new string[6,6];
    DierkNinjaTrader Customer Service

    Comment


      #3
      Originally posted by NinjaTrader_Dierk View Post
      Please try
      private string[,] = new string[6,6];
      Tried that:

      Array = new string[6,6];
      Array[0,534.2]="Test";

      Compiling this causes this:
      Cannot implicitly convert type 'double' to 'int'. An explicit conversion exists (are you missing a cast?)
      cassb
      NinjaTrader Ecosystem Vendor - Logical Forex

      Comment


        #4
        My apologies, edited post below.

        Also array indexes needed to be int not double.

        Note: these are basic C# programming question. Unfortunately we can't provide support level down to that level.
        DierkNinjaTrader Customer Service

        Comment


          #5
          Originally posted by NinjaTrader_Dierk View Post
          My apologies, edited post below.
          It wants integers for the array subscripts. I can't use a double value for a subscript. Maybe I need an array within an array? I don't understand why this concept is so complex in C#.

          Think of what I'm trying to do as:

          Array[Bar Number,Price] = "Text"
          cassb
          NinjaTrader Ecosystem Vendor - Logical Forex

          Comment


            #6
            Originally posted by cassb View Post
            It wants integers for the array subscripts. I can't use a double value for a subscript. Maybe I need an array within an array? I don't understand why this concept is so complex in C#.

            Think of what I'm trying to do as:

            Array[Bar Number,Price] = "Text"

            Just a note in case someone is looking at this thread in the future -- I decided to just convert the price to an integer and convert it back to double when needed. To convert to integer, where pricedecimals is the number of decimals in TickSize:

            x = Convert.ToInt16(price*(10^pricedecimals))
            Array[0,x]="text"

            To reconvert back to price:

            price = Convert.ToDouble(x/(10^pricedecimals))
            cassb
            NinjaTrader Ecosystem Vendor - Logical Forex

            Comment


              #7
              The mixed arrays type is removed from .NET 4.0. I have not really seen any use of mixed arrays.


              .Net Training in chennai

              Comment


                #8
                Please check the below given link may be it will be help you.
                php interview questions

                Comment

                Latest Posts

                Collapse

                Topics Statistics Last Post
                Started by johnnybegoode, Yesterday, 10:06 PM
                0 responses
                4 views
                0 likes
                Last Post johnnybegoode  
                Started by stasha, Yesterday, 07:35 PM
                1 response
                10 views
                0 likes
                Last Post stasha
                by stasha
                 
                Started by johnnybegoode, Yesterday, 07:06 PM
                0 responses
                11 views
                0 likes
                Last Post johnnybegoode  
                Started by contrax, 10-02-2017, 05:32 PM
                8 responses
                2,131 views
                0 likes
                Last Post NinjaTrader_Jesse  
                Started by lehula, 01-09-2019, 04:39 PM
                4 responses
                24 views
                0 likes
                Last Post NinjaTrader_PaulH  
                Working...
                X