473,403 Members | 2,071 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,403 software developers and data experts.

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.
Nov 17 '05 #1
4 1841
string[][] topmenu = {new string[] {"menu1", "aaa"},new string[]{"menu2",
"bbb"}};

"George Ter-Saakov" <we@hotmail.com> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
I need to declare const 2 dimensional array

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

Thanks.
George.

Nov 17 '05 #2
string[,] siblings = new string[2, 2] { {"Mike","Amy"}, {"Mary","Albert"} };

"George Ter-Saakov" <we@hotmail.com> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
I need to declare const 2 dimensional array

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

Thanks.
George.

Nov 17 '05 #3
Tap
George,

Hope following code helps you.....

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

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

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

Thanks,

Tap
-----Original Message-----
I need to declare const 2 dimensional array

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

Nov 17 '05 #4
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)" <sq**********@hotmail.com> wrote in message
news:uF**************@TK2MSFTNGP12.phx.gbl...
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:%2****************@TK2MSFTNGP10.phx.gbl...
I need to declare const 2 dimensional array

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

Thanks.
George.


Nov 17 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Dylan Nicholson | last post by:
Is there any way of declaring the parameter "array" below to be const, so that the function as written will not compile: void foo(int array /*const*/) { array = array; // should not be allowed...
5
by: Ingo Brueckl | last post by:
I need to declare a fixed array of (already defined and working) sort functions (sortfunc1, sortfunc2, sortfunc3) to pass one element of the array to qsort itself: int index; ??? func =...
23
by: mark.moore | last post by:
I know this has been asked before, but I just can't find the answer in the sea of hits... How do you forward declare a class that is *not* paramaterized, but is based on a template class? ...
8
by: redefined.horizons | last post by:
I would like to have an array declaration where the size of the array is dependent on a variable. Something like this: /* Store the desired size of the array in a variable named "array_size". */...
3
by: johnmmcparland | last post by:
Hi all, I would like to have a static constant array inside a class definition which would contain the number of days in each month (I am writing a Date class as an exercise). However my...
1
by: peary | last post by:
Hi, everyone, I'm writing a program to discover wireless network using Windows Native Wifi API & VB.net. I have to declare the windows API in my VB.net program. The original windows...
2
by: vishwesha.guttal | last post by:
Hi, I am having troble declaring a const array. If the array size is small, then one can do as follows: const double array = {1, 2, 3, 4, 5}; What if I have an array of size say 1000 or...
10
by: Stephen Howe | last post by:
Hi Just going over some grey areas in my knowledge in C++: 1) If I have const int SomeConst = 1; in a header file, it is global, and it is included in multiple translations units, but it...
10
by: Tammy | last post by:
Hello all, I am wondering what is the best way to declare a struct to be used in other c and c++ files. Such as for a C API that will be used by others. 1. Declaring the typedef and the...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.