.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Gaurav Pal

Home >> Articles >> .Net Framework >> Post New Resource Bookmark and Share   

 Subscribe to Articles

Specialized String Collection Classes

Posted By:Hefin Dsouza       Posted Date: September 07, 2009    Points: 25    Category: .Net Framework    URL: http://www.dotnetspark.com  

Specialized String Collection Classes.

Strings the most commonly used data type .At times we may also use strings in Collections. The .NET Framework provides special collection types to store string values which are the StringDictionary and the StringCollection classes which are from the System.Collections.Specialized.

Using the StringCollection

The StringCollection class is a collection type used to store only string values the benefits of using StringCollection type is its type safe to use it when one is working with collection of string values.

StringCollection names=new StringCollection();
names.Add("Visual Basic");
string val=names[1];//Does not need type casting like in ArrayList


Now for the StringDictionary class.
This class is similar to the HashTable class except for the keys and the values both have to be strings.

StringDictionary myDict=new StringDictionary();
myDict["a"]="MyWorld" // Note that the keys are by default case insensitive
myDict.Add("B","Cool World");
string getVal=myDict["B"];

Hope these new specialized collection types for strings come handy for you.

Hefin Dsouza

 Subscribe to Articles


Further Readings:


No response found. Be the first to respond this post

Post Comment

You must Sign In To post reply
Find More Articles on C#, ASP.Net, Vb.Net, SQL Server and more Here

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend