how do i declare const array?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • George Ter-Saakov

    #1

    how do i declare const array?

    I need to declare const 2 dimensional array

    something like
    string[][2] topmenu = { {"menu1", "aaa"}, {"menu2", "bbb"} }

    Thanks.
    George.


  • MS News \(MS ILM\)

    #2
    Re: how do i declare const array?

    string[][] topmenu = {new string[] {"menu1", "aaa"},new string[]{"menu2",
    "bbb"}};

    "George Ter-Saakov" <we@hotmail.com > wrote in message
    news:%237fJDLMa DHA.2072@TK2MSF TNGP10.phx.gbl. ..[color=blue]
    > I need to declare const 2 dimensional array
    >
    > something like
    > string[][2] topmenu = { {"menu1", "aaa"}, {"menu2", "bbb"} }
    >
    > Thanks.
    > George.
    >
    >[/color]


    Comment

    • MS News \(MS ILM\)

      #3
      Re: how do i declare const array?

      string[,] siblings = new string[2, 2] { {"Mike","Amy "}, {"Mary","Albert "} };

      "George Ter-Saakov" <we@hotmail.com > wrote in message
      news:%237fJDLMa DHA.2072@TK2MSF TNGP10.phx.gbl. ..[color=blue]
      > I need to declare const 2 dimensional array
      >
      > something like
      > string[][2] topmenu = { {"menu1", "aaa"}, {"menu2", "bbb"} }
      >
      > Thanks.
      > George.
      >
      >[/color]


      Comment

      • Tap

        #4
        how do i declare const array?

        George,

        Hope following code helps you.....

        // Single-dimensional arrays.
        int[] myArray1 = new int [5];
        string[] myArray2 = new string[6];

        // Multidimensiona l arrays.
        int[,] myArray3 = new int[4,2];
        int[,,] myArray4 = new int [4,2,3];

        // Jagged array.
        int[][] myArray5 = new int[3][];

        Thanks,

        Tap[color=blue]
        >-----Original Message-----
        >I need to declare const 2 dimensional array
        >
        >something like
        >string[][2] topmenu = { {"menu1", "aaa"},[/color]
        {"menu2", "bbb"} }[color=blue]
        >
        >Thanks.
        >George.
        >
        >
        >.
        >[/color]

        Comment

        • George Ter-Saakov

          #5
          Re: how do i declare const array?

          None of it works with const.

          const string[,] siblings = { {"Gus", "Amy"}, {"Mary", "Albert"} }; - error

          Array initializers can only be used in a variable or field initializer. Try
          using a new expression instead.


          George.

          "MS News (MS ILM)" <sql_agentman@h otmail.com> wrote in message
          news:uFfYefMaDH A.2352@TK2MSFTN GP12.phx.gbl...[color=blue]
          > string[][] topmenu = {new string[] {"menu1", "aaa"},new string[]{"menu2",
          > "bbb"}};
          >
          > string[,] siblings = { {"Gus", "Amy"}, {"Mary", "Albert"} };
          >
          > string[,] siblings2 = new string[,] { {"Gus","Amy" }, {"Mary","Albert "} };
          >
          > "George Ter-Saakov" <we@hotmail.com > wrote in message
          > news:%237fJDLMa DHA.2072@TK2MSF TNGP10.phx.gbl. ..[color=green]
          > > I need to declare const 2 dimensional array
          > >
          > > something like
          > > string[][2] topmenu = { {"menu1", "aaa"}, {"menu2", "bbb"} }
          > >
          > > Thanks.
          > > George.
          > >
          > >[/color]
          >
          >[/color]


          Comment

          Working...