473,378 Members | 1,422 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,378 software developers and data experts.

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 2180
You can't - check out ArrayList.

--
Adam Clauss
ca*****@tamu.edu
"Spare Change" <sp*********@spam.spam> wrote in message news:ZX***************@newsread3.news.pas.earthlin k.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.StringBuilder

Marijan
"Spare Change" <sp*********@spam.spam> wrote in message
news:ZX***************@newsread3.news.pas.earthlin k.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+"#"+m1.Value.Substring(5,m1.Length-5);
anchors=temp;
}
Marijan Tadin wrote:
Try Sytem.Text.StringBuilder

Marijan
"Spare Change" <sp*********@spam.spam> wrote in message
news:ZX***************@newsread3.news.pas.earthlin k.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**********@planet.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*********@spam.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.Collections.Specialized;

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

int len=sc.Count;
string[] strings=new string[len];
sc.CopyTo(strings,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**********@planet.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.Collections.Speciallized.StringCollecion 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**********@planet.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
On Sun, 05 Sep 2004 03:43:53 GMT, "Spare Change"
<sp*********@spam.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.Collections.Specialized;

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

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

Austin Ehlers
Jul 21 '05 #11
Scott,

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

:-)

Thanks,

Cor
Jul 21 '05 #12
>
I see no evidence, that once declared, that a primitive string[] can be
'ReDim'ed


I hope I am not wrong in this way, however as far as I know are there some
differences between the Array and in C# and VBNet.

In VBNet there is the Redim, however I would only using that when converting
a program from VB6 to VBNet and even than check for it and replace when that
is in it directly for a more dynamic one as I showed in a previous message
in this thread.

Redim seems to be a very performance consuming instruction.

Just my thought,

Cor
Jul 21 '05 #13
That is just mad!

"The Devil" <el******@hadez.nyc.spamo> wrote in message
news:yA*****************@newsread1.news.pas.earthl ink.net...

I went with a resizing routine.

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

Marijan
"Spare Change" <sp*********@spam.spam> wrote in message
news:ZX***************@newsread3.news.pas.earthlin k.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 #14

System.Collections.Specialized.StringCollection should do. The interface is
very similar to string[] (except that Length is changed to Count) and you
can do Add()/Remove().

Jarek

"Paul Wardle" <p.******@ntlworld.com> wrote in message
news:ue**************@TK2MSFTNGP14.phx.gbl...
That is just mad!

"The Devil" <el******@hadez.nyc.spamo> wrote in message
news:yA*****************@newsread1.news.pas.earthl ink.net...

I went with a resizing routine.

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

Marijan
"Spare Change" <sp*********@spam.spam> wrote in message
news:ZX***************@newsread3.news.pas.earthlin k.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 #15

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

Similar topics

0
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...
6
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...
5
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...
3
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...
10
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
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...
2
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
by: MaryamSh | last post by:
Create Dynamic Dropdownlist Controls and related event -------------------------------------------------------------------------------- Hi, I am creating a Dynamic Search in my application. I...
2
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...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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...

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.