473,772 Members | 2,414 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

dynamic string[]

I am told that I can have a dynamic or static string array.

So if I declare

string[] dynamic;

How do I add elements to dynamic and resize it ?


---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.752 / Virus Database: 503 - Release Date: 9/3/2004
Jul 21 '05 #1
14 2245
You can't - check out ArrayList.

--
Adam Clauss
ca*****@tamu.ed u
"Spare Change" <sp*********@sp am.spam> wrote in message news:ZX******** *******@newsrea d3.news.pas.ear thlink.net...
I am told that I can have a dynamic or static string array.

So if I declare

string[] dynamic;

How do I add elements to dynamic and resize it ?


---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.752 / Virus Database: 503 - Release Date: 9/3/2004

Jul 21 '05 #2
Try Sytem.Text.Stri ngBuilder

Marijan
"Spare Change" <sp*********@sp am.spam> wrote in message
news:ZX******** *******@newsrea d3.news.pas.ear thlink.net...
I am told that I can have a dynamic or static string array.

So if I declare

string[] dynamic;

How do I add elements to dynamic and resize it ?


---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.752 / Virus Database: 503 - Release Date: 9/3/2004


Jul 21 '05 #3

I went with a resizing routine.

foreach(Match m1 in mc1)
{
temp = new string[i+1];
anchors.CopyTo( temp,0);
temp[i++]=fileName+"#"+m 1.Value.Substri ng(5,m1.Length-5);
anchors=temp;
}
Marijan Tadin wrote:
Try Sytem.Text.Stri ngBuilder

Marijan
"Spare Change" <sp*********@sp am.spam> wrote in message
news:ZX******** *******@newsrea d3.news.pas.ear thlink.net...
I am told that I can have a dynamic or static string array.

So if I declare

string[] dynamic;

How do I add elements to dynamic and resize it ?


---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.752 / Virus Database: 503 - Release Date: 9/3/2004


--
incognito http://kentpsychedelic.blogspot.com
new material added 9/5
Jul 21 '05 #4
Spare,

You declare a "static" string as

string[10] dynamic;

A nice string with a fixed lenght with the name dynamic.

For dynamic array typen check all the iList collections (from which is the
fixex lenght array one)
http://msdn.microsoft.com/library/de...classtopic.asp

For even more have a look at the link iCollection on that bottom of that
page

I hope this helps?

Cor
Jul 21 '05 #5
Hi Cor:

Just to avoid confusion:
You declare a "static" string as

string[10] dynamic;
The above would lead to a compiler error.

This:

string[] dynamic = new string[10];

Would create a single dimensional array of string types.

--
Scott
http://www.OdeToCode.com
On Sun, 5 Sep 2004 12:12:34 +0200, "Cor Ligthert"
<no**********@p lanet.nl> wrote:
Spare,

You declare a "static" string as

string[10] dynamic;

A nice string with a fixed lenght with the name dynamic.

For dynamic array typen check all the iList collections (from which is the
fixex lenght array one)
http://msdn.microsoft.com/library/de...classtopic.asp

For even more have a look at the link iCollection on that bottom of that
page

I hope this helps?

Cor


Jul 21 '05 #6
On Sun, 05 Sep 2004 03:43:53 GMT, "Spare Change"
<sp*********@sp am.spam> wrote:
I am told that I can have a dynamic or static string array.

So if I declare

string[] dynamic;

How do I add elements to dynamic and resize it ?


using System.Collecti ons.Specialized ;

....
StringCollectio n sc=new StringCollectio n();
sc.Add(str1);
....
//get a real string[] when done if needed

int len=sc.Count;
string[] strings=new string[len];
sc.CopyTo(strin gs,0);

Austin Ehlers
Jul 21 '05 #7

Yes, you are quite right.

But, I read that string[] can be dynamic.

I see no evidence, that once declared, that a primitive string[] can be
'ReDim'ed

:D

Scott Allen wrote:
Hi Cor:

Just to avoid confusion:
You declare a "static" string as

string[10] dynamic;


The above would lead to a compiler error.

This:

string[] dynamic = new string[10];

Would create a single dimensional array of string types.

--
Scott
http://www.OdeToCode.com
On Sun, 5 Sep 2004 12:12:34 +0200, "Cor Ligthert"
<no**********@p lanet.nl> wrote:
Spare,

You declare a "static" string as

string[10] dynamic;

A nice string with a fixed lenght with the name dynamic.

For dynamic array typen check all the iList collections (from which is the
fixex lenght array one)
http://msdn.microsoft.com/library/de...classtopic.asp

For even more have a look at the link iCollection on that bottom of that
page

I hope this helps?

Cor


Jul 21 '05 #8
I don't know of any way in c# to implicitly resize a string array.
Consider using System.Collecti ons.Speciallize d.StringColleci on class.
It's a strongly-typed collection, something like an array list, but
for strings, so there is no performance hit for boxing.
Jul 21 '05 #9
Hi Cor:

Just to avoid confusion:
You declare a "static" string as

string[10] dynamic;
The above would lead to a compiler error.

This:

string[] dynamic = new string[10];

Would create a single dimensional array of string types.

--
Scott
http://www.OdeToCode.com
On Sun, 5 Sep 2004 12:12:34 +0200, "Cor Ligthert"
<no**********@p lanet.nl> wrote:
Spare,

You declare a "static" string as

string[10] dynamic;

A nice string with a fixed lenght with the name dynamic.

For dynamic array typen check all the iList collections (from which is the
fixex lenght array one)
http://msdn.microsoft.com/library/de...classtopic.asp

For even more have a look at the link iCollection on that bottom of that
page

I hope this helps?

Cor


Jul 21 '05 #10

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

Similar topics

0
3517
by: starace | last post by:
I have designed a form that has 5 different list boxes where the selections within each are used as criteria in building a dynamic query. Some boxes are set for multiple selections but these list boxes do not necessarily need to have a selection made to be used in the dynamic query. In essence the form can have selections made in all or none of its list boxes to form the dynamic query I am looking to get some feedback in reference to...
6
2981
by: Materialised | last post by:
Hi Everyone, I apologise if this is covered in the FAQ, I did look, but nothing actually stood out to me as being relative to my subject. I want to create a 2 dimensional array, a 'array of strings'. I already know that no individual string will be longer than 50 characters. I just don't know before run time how many elements of the array will be needed. I have heard it is possible to dynamically allocate memory for a 2
5
3760
by: swarsa | last post by:
Hi All, I realize this is not a Palm OS development forum, however, even though my question is about a Palm C program I'm writing, I believe the topics are relevant here. This is because I believe the problem centers around my handling of strings, arrays, pointers and dynamic memory allocation. Here is the problem I'm trying to solve: I want to fill a list box with a list of Project Names from a database (in Palm this is more...
3
1312
by: Stephen Gennard | last post by:
Hello, I having a problem dynamically invoking a static method that takes a reference to a SByte*. If I do it directly it works just fine. Anyone any ideas why? I have include a example below... --
10
34105
by: Spare Change | last post by:
I am told that I can have a dynamic or static string array. So if I declare string dynamic; How do I add elements to dynamic and resize it ?
7
22497
by: Mike Livenspargar | last post by:
We have an application converted from v1.1 Framework to v2.0. The executable references a class library which in turn has a web reference. The web reference 'URL Behavior' is set to dynamic. We added an entry to the executable's .exe.config file to specify the URL, and under the 1.1 framework this worked well. Unfortunately, this is not working under the 2.0 framework. I see in the Reference.cs file under the web service reference the...
2
3639
by: Luis Arvayo | last post by:
Hi, In c#, I need to dynamically create types at runtime that will consist of the following: - inherits from a given interface - will have a constructor with an int argument
0
3501
by: MaryamSh | last post by:
Create Dynamic Dropdownlist Controls and related event -------------------------------------------------------------------------------- Hi, I am creating a Dynamic Search in my application. I create a user control and in Page_load event I create a dynamic dropdownlist and 2 dynamic button (Add,Remove) By pressing Add button ,another row will be created with the same control (I mean another dropdown and 2 button) and so on. and by...
2
5035
by: englishman69 | last post by:
Hello, I have been banging my head against this one for a while... Searches online have revealed many different proposals for correcting my issue but none that I can follow! My basic situation is this, I have a page which uses multiple postbacks to generate a list of dynamic text boxes with appropriate labels. However, when I do the final postback to enter the values in the dynamic textboxes into the database the values seem to become...
0
9619
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10261
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10103
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10038
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9911
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7460
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5354
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5482
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3609
muto222
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.