Hi Davið,
(string) is a cast. It is used for type conversion (between class names,
structs, interfaces etc). It indicates that sampleConfig["Title"] returns
something other than a string, typically an object. To be able to use
this object as a string you first need to cast it back to a string, by
using (string).
Consider object o = 1;
int i = o;
Now, even though o contains a number, it cannot be directly stored as an
int. You need to tell the compiler you are aware of the dangers by
putting (int) in front of o.
int i = (int)o;
Casting changes the "appearance" of the object and you need to cast to the
correct class to be able to perform specific tasks on the objects.
Consider an ArrayList. It can hold any number of objects, and all
different kinds of objects at the same time.
However, internally, the ArrayList considers all these objects to be of
type Object, the basic type all other types in .Net Framework inherits
from. When you retrieve an object from an ArrayList it returns the Object
"signature" so no matter what type it was when you put it in, you cannot
do anything with it other than the stuff belonging to Object, like
ToString() and GetType(). You need to cast the object back to the
original type (class, struct, interface, etc).
ArrayList a = new ArrayList();
string s = "hello world";
a.Add(s);
string s = (string)a[0]; // a[0] returns an Object
Don't confuse the class type Object with the "physical" object (the thing,
which can be any class, struct, value, array, enum, interface ...).
I'm not sure if this helps you in any way, and some further code samples
might be in order, but perhaps others can fill in.