|
-
Nov 6th, 2003, 07:19 PM
#1
Thread Starter
Addicted Member
Create array from unknown amount of elements
I am doing a regex match and I want to add the results to a 2 dimensional array where the array, but I do not know how many matches there will be and I don't want to set some insane length for the array. Can someone help me out with this I'm sure its simple.
-
Nov 6th, 2003, 11:40 PM
#2
Frenzied Member
Try this.
Code:
string [,]match = new string[numOfMatches, numOfMatches];
-
Nov 7th, 2003, 05:34 AM
#3
Hyperactive Member
Hey,
if you have a unique value you should use a hashtable. A hashtable always needs a unique key and a matching value for it.
Heres an example of how to use a hashtable:
Code:
.
.
.
using System.Collections;
.
.
.
Hashtable myTable = new Hashtable();
myTable.Add("key","value");
IDictionaryEnumerator em = myTable.GetEnumerator();
while (em.MoveNext())
{
myKeyString = em.Key.ToString()
myKeyValue = em.Value.ToString()
}
.
.
.
Hope I could help!,
Stephan
BTW: If you do not have a unique key to use try vector!
Keep Smiling - even if its hard 
Frankie Says Relax, wossname Says Yeah!
wossname:--Currently I'm wearing a gimp suit and a parachute.
C# - Base64 Blog
-
Nov 7th, 2003, 12:52 PM
#4
Thread Starter
Addicted Member
DevGrp - I dont want to have to loop through the matches just so i can declare the array and loop again. What I'm looking for is like a way to resize the array an not lose the values like VB's ReDim Preserve method.
Sgt-Peppa - thanks I think that will do.
Last edited by Tewl; Nov 7th, 2003 at 12:55 PM.
-
Nov 7th, 2003, 04:08 PM
#5
PowerPoster
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|