Specialized String Collection Types in .NET 2.0

Posted by in C# category on for Intermediate level | Views : 8615 red flag

This article will introduce some of the String Specialized Classes in DotNet Framework 2.0

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

First we see 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 stringColl=new StringCollection();
stringColl.Add("Visual Basic");
string val=stringColl[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 strDic=new StringDictionary();
strDic["a"]="MyWorld" // Note that the keys are by default case insensitive
strDic.Add("B","Cool World");
string getVal=strDic["B"];

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

Hefin Dsouza

Page copy protected against web site content infringement by Copyscape

About the Author

Full Name: Hefin Dsouza
Member Level: Starter
Member Status: Member
Member Since: 9/16/2009 12:32:23 PM
Country: India

My Name is Hefin Dsouza. I am a faculty at Computer Education Institute.I am also an Freelance Software Developer and Software Trainner.I am working with DotNet Technologies from the past 8 years.I am an Microsoft Certified Windows Application Developer for .NET 3.5. And also a Blogger at http://blog.hefin.in

Login to vote for this post.

Comments or Responses

Login to post response

Comment using Facebook(Author doesn't get notification)