r/UnityHelp • • Nov 30 '21

Can someone explain why this string equality doesn't work before i run into a wall head-first

if (data[1][0] == data[2][4]) .....this doesnt work although the string underneath is identical when I debug. why??

if (data[1][0] == name)...... this doesnt work either.. unless i do 'name = "the string here". why???

Im 8 hours in and have scoured google, reddit, stackoverflow, microsoft docs.. please help!

3 Upvotes

3 comments sorted by

3

u/Fancy_Edge2509 Nov 30 '21

It was whitespace argh!

1

u/cone5000 Nov 30 '21

Next time you could do

if (data[1][0].Trim() == data[2][4].Trim())

2

u/Fancy_Edge2509 Nov 30 '21

I certainly will, appreciated 😊 🙏