substring - Weird behavior with indexof method in c# -
i have code, entities
list <string>
received parameter. tried cast entities[x]
string in way possible, being string. checked entities[x] string
returning true
.
for(int x = 0; x < entities.count; x++) { console.writeline(entities[x] + " " + "a pencil g smartboard tabletc pencil ".indexof(entities[x])); }
the result is:
pencil 30 smartboard 11 tabletc -1
why indexof returns -1 "tabletc"?
the string input begins backspace character, ascii 8.
try like
"... \btabletc ...".indexof(entities[2])
where \b
means backspace character.
Comments
Post a Comment