Tutorial :: String is an Array of Characters

Well, we all know about variables and objects, thus not elaborating them. But many of us think that string is also like other variables. But thats not true. There are two kinds of data types, Value Types and Reference Types. From the book "Professional Visual Basic 2008" by Bill Evjen, Billy Hollis, Bill Sheldon and Kent Sharkey we get the followings,

Value types represent simple data storage located on the stack. The stack is used for items of a
known size, so items on the stack can be retrieved

faster than those on the managed heap.

Reference types are based on complex classes with implementation inheritance from their parent
classes, and custom storage on the managed heap. The managed heap is optimized to support
dynamic allocation of differently sized objects.

That is, value types (integer, float, boolean etc) allocates a particular amount of memory whenever they are declared, but Strings (Reference Types) do not allocates a particular amount of memory. Memory allocation is dynamic in that case. That book describes lot more about Value and Reference Types.

Actually, String is an array of characters. Whenever we type something and store it in a String, we are actually using an array of characters.  Its like if have done the following,

Dim myString = new String();   'look here, we have initialized the string using the constructor function of the class String

myString = "We shall overcome"

Then, you can enter each character of your string just like the following, myString(position_number). For example, let us take a textbox named myTextbox and if we do the following,

myTextbox.Text = myString(5)

Then the output in myTextbox will be 


In languages like JAVA, VB.NET I found String as the most powerful object to use for various manipulations. Learning and practicing String manipulation is very important from my view.

Now in the very next post to it, we will see some codes related string manipulation.

Thanks for reading.



Contact Us