Click here to Skip to main content
15,905,915 members
Please Sign up or sign in to vote.
3.00/5 (1 vote)
See more:
Hi,

I need to perform some operations on string, like add a string, remove and search.

the values which i need to use is a compination of section name and sub section name (Both are string). I got three suggestion how to do this one in C#. (both section name and SubSection name of length 50 characters, and the max number of this combination is 500)

1. Use List<string> (to store we can use string concatenation)

2. Use StringBuilder (Concatenate and use append)

3. Use List<string,string> (save individual strings)

Which one will give a better performance and memory management. Can any one please suggest the best choice from above.

Am using C# with Framework 2.0



Thanks in Advance,

Nidheesh
Posted

I would go for the StringBuilder option.
Removing from the StringBuilder class maybe slight more complex.

A list is not really necessary unless you need something really complex (besides basic append, search, replace) to be implemented.
 
Share this answer
 
Comments
Varun Sareen 22-Feb-12 4:42am    
my 4: good call
Abhinav S 22-Feb-12 6:21am    
Thank you.
Why don't you use 'the experimental approach'?
Design a test to compare the performances of the depicted methods.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900