.NETGURU
dynamic string
Messages   Related Types
This message was discovered on microsoft.public.dotnet.general.

Post a new message to this list...

Spare Change
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

Reply to this message...
 
    
Chad Chisholm
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.
Reply to this message...
 
    
Austin Ehlers
On Sun, 05 Sep 2004 03:43:53 GMT, "Spare Change"
<Click here to reveal e-mail address> wrote:

[Original message clipped]

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
Reply to this message...
 
    
Marijan Tadin
Try Sytem.Text.StringBuilder

Marijan

"Spare Change" <Click here to reveal e-mail address> wrote in message
news:ZXv_c.660$Click here to reveal e-mail address...
[Original message clipped]

Reply to this message...
 
    
The Devil
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:

[Original message clipped]

--
incognito http://kentpsychedelic.blogspot.com
new material added 9/5
Reply to this message...
 
    
Paul Wardle
That is just mad!

"The Devil" <Click here to reveal e-mail address> wrote in message
news:yAA_c.7884$w%Click here to reveal e-mail address...
[Original message clipped]

Reply to this message...
 
    
Jaroslaw Kowalski
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" <Click here to reveal e-mail address> wrote in message
news:Click here to reveal e-mail address...
[Original message clipped]

Reply to this message...
 
    
Adam Clauss
You can't - check out ArrayList.

--
Adam Clauss
Click here to reveal e-mail address
"Spare Change" <Click here to reveal e-mail address> wrote in message news:ZXv_c.660$Click here to reveal e-mail address...
[Original message clipped]

Reply to this message...
 
    
Cor Ligthert
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/default.asp?url=/library/en-us/cpref/html/frlrfsystemcollectionsicollectionclasstopic.asp

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

I hope this helps?

Cor

Reply to this message...
 
    
Scott Allen
Hi Cor:

Just to avoid confusion:

[Original message clipped]

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"
<Click here to reveal e-mail address> wrote:

[Original message clipped]

Reply to this message...
 
    
i will now proceed to entangle the entire area
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:

[Original message clipped]

Reply to this message...
 
    
Cor Ligthert
[Original message clipped]

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

Reply to this message...
 
    
Cor Ligthert
Scott,

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

:-)

Thanks,

Cor

Reply to this message...
 
 
System.Collections.ArrayList
System.Collections.Specialized.StringCollection




ExamGuru IT Solutions - .Net Guru is owned and operated by ExamGuru, Inc., the man behind .Net Guru. If you're in the market for bespoke software or software consultancy, why not get him and his highly trained team to help? - www.examguru.net/ITCertification
Ad


Need Dot Net Interview Questions?
Ask ExamGuru, Inc. for advice and help on Passing .Net Interviews
.Net Projects
Best-of-breed application framework for .NET projects, developed by ExamGuru, Inc. and ExamGuru IT
Free .net Help
Commission ExamGuru, Inc. and his team for your next bespoke software project
FogBUGZ
The only bug tracking system carefully crafted with one goal in mind: helping teams create great software.
Awesome Tools
If you don't know about these, you're missing out... IT Certification Questions
IT Interview Questions
Free Oracle 10g Training
MCSE Boortcamp
Cisco Study Guides
Cheap Study Guides
Exact Questions
Dot Net Interview Questions
Oracle OCP
Cheap Travel
Designer Perfumes - Wholesale Prices
Free Programming Tutorials
 
ExamGuru IT Solutions - .Net Guru is owned and operated by ExamGuru, Inc., the man behind .Net Guru. If you're in the market for bespoke software or software consultancy, why not get him and his highly trained team to help? - www.examguru.net/ITCertification
 Copyright © ExamGuru, Inc. 2001-2006
Contact Us - Terms of Use - Privacy Policy - www.dot-net-guru.com - www.examguru.net - www.oraclesource.net - www.itinterviews.net - www.examguru.net/ITCertification