473,786 Members | 2,571 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
Nov 16 '05 #1
10 34106
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

Nov 16 '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


Nov 16 '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
Nov 16 '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
Nov 16 '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


Nov 16 '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
Nov 16 '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


Nov 16 '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.
Nov 16 '05 #9
Scott,

I should avoid writting C# code and not using the IDE.
(I write everything automaticly in a VBNet way)

:-)

Thanks,

Cor
Nov 16 '05 #10

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

Similar topics

5
2379
by: K | last post by:
I have found a script online that I want to use (I am new to PHP). It creates dynamic images based on the text that you pass it. However, no matter how I try, I can't get anything other than a blank white image. Can one of you knowledgeable people please have a look at the code below and help please.
14
2249
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 ?
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
2983
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... --
7
22498
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
5036
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
9497
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10363
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...
1
10110
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
9962
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
7515
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
6748
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5534
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4067
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3670
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.