473,471 Members | 1,977 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Array

Hello,

Could someone tell me how to create an array of strings?

Thanks,
Miguel

Oct 4 '06 #1
4 1634
To create an array of a particular size, try the following

string[] myArray = new string[5];

this wuold create an array of 5 strings in C#. There are also array and
collection classes in the System.Collections namespace that can be of help,
such as the NameValueCollection when you need an array of name/value pairs.

Hope this helps,
Mark Fitzpatrick
Microsoft MVP - FrontPage

"shapper" <md*****@gmail.comwrote in message
news:11*********************@k70g2000cwa.googlegro ups.com...
Hello,

Could someone tell me how to create an array of strings?

Thanks,
Miguel

Oct 4 '06 #2
Wrong signature (not to be misleading), should be former MVP
--
Hope this helps,
Mark Fitzpatrick
Former Microsoft FrontPage MVP 199?-2006

"Mark Fitzpatrick" <ma******@fitzme.comwrote in message
news:u7**************@TK2MSFTNGP02.phx.gbl...
To create an array of a particular size, try the following

string[] myArray = new string[5];

this wuold create an array of 5 strings in C#. There are also array and
collection classes in the System.Collections namespace that can be of
help, such as the NameValueCollection when you need an array of name/value
pairs.

Hope this helps,
Mark Fitzpatrick
Microsoft MVP - FrontPage

"shapper" <md*****@gmail.comwrote in message
news:11*********************@k70g2000cwa.googlegro ups.com...
>Hello,

Could someone tell me how to create an array of strings?

Thanks,
Miguel


Oct 4 '06 #3
If you don't know the size of the array needed up front, use a collection.

In 2.0, you can use a generic:

List<string myArray = new List<string>();

and then you can do

myArray.Add("1");

in 1.x, use an ArrayList:

ArrayList arr = new ArrayList();
arr.Add("1");
Karl

--
http://www.openmymind.net/
http://www.codebetter.com/
"shapper" <md*****@gmail.comwrote in message
news:11*********************@k70g2000cwa.googlegro ups.com...
Hello,

Could someone tell me how to create an array of strings?

Thanks,
Miguel

Oct 4 '06 #4
Thank you!

Karl Seguin [MVP] wrote:
If you don't know the size of the array needed up front, use a collection.

In 2.0, you can use a generic:

List<string myArray = new List<string>();

and then you can do

myArray.Add("1");

in 1.x, use an ArrayList:

ArrayList arr = new ArrayList();
arr.Add("1");
Karl

--
http://www.openmymind.net/
http://www.codebetter.com/
"shapper" <md*****@gmail.comwrote in message
news:11*********************@k70g2000cwa.googlegro ups.com...
Hello,

Could someone tell me how to create an array of strings?

Thanks,
Miguel
Oct 4 '06 #5

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

Similar topics

2
by: Brian | last post by:
I'm diddlying with a script, and found some behavior I don't understand. Take this snippet: for ($i = 0; $i <= count($m); $i++) { array_shift($m); reset($m); }
2
by: Stormkid | last post by:
Hi Group I'm trying to figure out a way that I can take two (two dimensional) arrays and avShed and shed, and subtract the matching elements in shed from avShed I've pasted the arrays blow from a...
15
by: lawrence | last post by:
I wanted to test xml_parse_into_struct() so I took the example off of www.php.net and put this code up on a site: <?php $simple = <<<END <item>
8
by: vcardillo | last post by:
Hello all, Okay, I am having some troubles. What I am doing here is dealing with an employee hierarchy that is stored in an array. It looks like this: $employees = array( "user_id" => array(...
12
by: Sam Collett | last post by:
How do I remove an item with a specified value from an array? i.e. array values 1,2,2,5,7,12,15,21 remove 2 from array would return 1,5,7,12,15,21 (12 and 21 are NOT removed, duplicates are...
8
by: Mike S. Nowostawsky | last post by:
I tried using the "toUpperCase()" property to change the value of an array entity to uppercase BUT it tells me that the property is invalid. It seems that an array is not considered an object when...
58
by: jr | last post by:
Sorry for this very dumb question, but I've clearly got a long way to go! Can someone please help me pass an array into a function. Here's a starting point. void TheMainFunc() { // Body of...
104
by: Leszek | last post by:
Hi. Is it possible in javascript to operate on an array without knowing how mamy elements it has? What i want to do is sending an array to a script, and this script should add all values from...
7
by: Jim Carlock | last post by:
Looking for suggestions on how to handle bad words that might get passed in through $_GET variables. My first thoughts included using str_replace() to strip out such content, but then one ends...
17
by: =?Utf-8?B?U2hhcm9u?= | last post by:
Hi Gurus, I need to transfer a jagged array of byte by reference to unmanaged function, The unmanaged code should changed the values of the array, and when the unmanaged function returns I need...
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
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
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
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
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...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.