Hey there,
I’m currently stuck on something I can’t wrap my head around, would someone be able to explain why this debug.Log returns 0 as a value, throwing a nullreference directly after.
string test = "";
for (int i = 0; i < names.lastNames.Count; i++)
{
if (names.lastNames[i].lastName.prefix != "") //if the prefix is not empty
{
test += names.lastNames[i].lastName.prefix; //add it
Debug.Log(test.Length); // Returns 0 ?
if (test[test.Length - 1] == ' ') // Throws nullreference
......
The same happens when trying to do this with stringbuilder.Append, stringbuilder.Length returns 0 and nullreference on the stringbuilder.Length when trying to check it.