duplicate StringCollections and RegEx problem

A

Andreas Bauer

Hi,

I have some question.
1. I have a filled StringCollection A. When I assign it to an
StringCollection B and remove a value from B, because strings are only
referenced, right? But now I need a copy of this StringCollection within
a function. How do I duplicate a StringCollection the easiest way? Do I
have to iterate through the StringCollection and copy the single values
one by one?
2. I have a function with an RegEx which extracts a value from a
logfile. When I look at the match of the RegEx everything is fine. But
when I look at the returned value within the calling function during
debugging, SharpDevelop shows me that there are strange things added to
the return string, e. g. "s)" or some windings like symbols or the
funniest
"c:\windows\assembly\gac_32\mscorlib\2.0.0.0_b77a5c561934e089\mscorlib.dll"
Does anybody have an idea why this happens? Is this a known bug of
SharpDevelop?

Best regards for your hints,

Andi
 
K

Klaas

As for 1:
StringCollection b = new StringCollection();

b.Add("Hello");

b.Add("World");

string[] s = new string[b.Count];

b.CopyTo(s, 0);

StringCollection c = new StringCollection();

c.AddRange(s);

foreach (string a in c)

{

System.Diagnostics.Debug.Write(a);

}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top