I am only getting the error for strings with more than one character. From what I have seen on the forums and from my own logic, Unity thinks that this is a list of characters, not strings. How do I fix this?
I managed to solve the issue by replacing the single quotes with double quotes, but why does this work?
Grant Thomas wrote this on Stack Overflow:
This is because, in C#, single quotes (ââ) denote (or encapsulate) a single character, whereas double quotes (ââ) are used for a string of characters. For example:
Itâs just how the compiler infers type with literals because they donât inherently have meaning.
23
^ Is this an int, a float, a string? By default the compiler will say itâs an integer, the safest guess. But if we put an f after it, it becomes a float and if we wrap it in quotes, it becomes a string.
Probably a hold over from C/C++. Strings in C# are not null terminated, but in C/C++ they are. âaâ is a single character, where as âaâ is a null terminated string. Itâs actually two bytes, one for âaâ and one for â\0â.