most likely this happens to you because this variable is not used anywhere in the code later on. If it sees that the variable is not used later, is it smart enough not to care about assigning a value to it.
to see if it works simply add this code after yours:
string s = name;